x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Property names are changed by UStructToJsonObjectString.

Hi, there: I'm trying Json-Request-Response in C++, and I use FJsonObjectConverter::UStructToJsonObjectString to convert a struct to a string, and found this api has an issue. this is my struct:alt text this is my code:alt text after conversion, the json string becomes:alt text the member variable "UserAccount" becomes "userAccount", "GUID" becomes "gUId", and "Password" becomes "password".

Cause I convert this string to struct in server by Java, the Json library in Java can't identify the struct if the case of member variable's name doesn't match.

Any advice will be thankful.

Product Version: Not Selected
Tags:
struct.png (17.3 kB)
code.png (20.0 kB)
jsonstring.png (8.0 kB)
more ▼

asked May 11 '15 at 09:45 AM in Bug Reports

avatar image

ZenTechEntertaiment
44 6 13 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey ZenTech-

It appears that the function FJsonObjectConverter::StandardizeCase() is converting the first character from uppercase to lowercase. If you're using a source version of the engine, changing the FJsonObjectConverter::UStructToJsonAttributes() function from FString VariableName = StandardizeCase(Property->GetName()); to FString VariableName = Property->GetName(); then it should match the name of the UPROPERTY on the struct after the conversion.

Cheers

Doug Wilson

more ▼

answered May 21 '15 at 04:09 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If I were to through a guess at this, I would assume it is because UE4 tries to adhere to variable naming conventions of camelCase, which for many programming languages starts with a lowercase (not with standing PascalCase, which starts with uppercase) and capitalizes the first letter of each word after. As in the case of UserAccount, in javascript for instance, the convention would be "userAccount". It is worth noting that JSON does stand for javaScriptObjectNotation.

I am not sure if I would agree with UE4 forcing conventions on coders, and I could be completely wrong.

You probably just need to adjust for the lowercase letters on the receiver.

more ▼

answered May 14 '15 at 06:59 AM

avatar image

tenowg
121 5 7 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question