FJsonObjectConverter::UStructToJsonObjectString

Hi, we’ve encountered an issue about property’s name in JsonObjectString, the situation is:
We have a UPROPERTY which’s type is FString named GUID.
If I launch UE4 Server from Editor and then the property’s name in JsonObjectString is “gUId”, but if I launch UE4 Server from a packaged server then it will be “guid”.

Thanks for your help .
Best regard.

Just a guess, but could GUID be protected? Have you tried renaming GUID to something else, like Id?

Nope, I’ve declared serval variables named GUID, others’s output will be “gUId”, only one will be “guid”.

Ah right, sorry then, I’ve got no more ideas. You’ll have to wait for someone with more xp at this which, unfortunately, is usually a very long time (if at all). Its a pity, but the community here is not very active - I suspect that it is because ue4 has not been around for as long as some others. Good luck!

Hi 任遊 陳龍進,

Where are you seeing this case error occur? Is it within a specific blueprint? Was the original name set to gUId and then altered later?

Nope, It’s a native C++ UPROPERTY in USTRUCT, And I called jsonconverter api in native C++ as well without blueprint. And the original name is “FString GUID”.

Inside JsonObjectConverter.cpp, the first function reads:

FString FJsonObjectConverter::StandardizeCase(const FString &StringIn)
{
	// this probably won't work for all cases, consider downcaseing the string fully
	FString FixedString = StringIn;
	FixedString[0] = FChar::ToLower(FixedString[0]); // our json classes/variable start lower case
	FixedString.ReplaceInline(TEXT("ID"), TEXT("Id"), ESearchCase::CaseSensitive); // Id is standard instead of ID, some of our fnames use ID
	return FixedString;
}

So, the logic seems to convert the first character to lowercase, and replace any ‘ID’ to 'Id", so “GUID” will be converted like this:

  1. “GUID” ==> “gUID”
  2. “gUID” ==> “gUId”

But as to why in the packaged game “GUID” becomes “guid”, I have no idea

I know, I’ve no idea either.

Hi 任遊 陳龍進,

I wanted to post to let you know I am still looking into this. Once I have more information I will post back here.

Try these changes to see if it alters the results:

  • Comment out the function block FJsonObjectConverter::StandardizeCase
  • Add string directly into FJsonObjectConverter::UStructtoJsonAttributes
  • Basically, comment out //FString VariableName = StandardizeCase (Property->GetName());
  • Next change OutJsonAttributes.Add(VariableName, JsonValue); to OutJsonAttributes.Add (Property->GetName(), JsonValue);

Please let me know if this addresses the error. If not, post back and I will continue looking for potential solutions to the errors you are seeing.

Hi 任遊 陳龍進,

We have not heard from you in several days. I am marking this thread as answered for tracking purposes. If you are still experiencing this issue, please comment with the requested information.