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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

UStructToJsonObject not working as expected since 4.13

I'm using FJsonObjectConverter::UStructToJsonObject to convert a struct to json object. And the struct has a UProperty of FJsonObjectWrapper. Something like this:

 struct FMyStruct
   UProperty() FJsonObjectWrapper SomeJsonObject;

Everything works fine at 4.12. However, since 4.13, it returns FJsonObjectWrapper as Json Value String instead of Json Value Object. Then everything break.

After reading the source code, I find the reason is that UE 4.13 added a function ExportTextItem to FJsonObjectWrapper. I don't know why this need to be added. Is this a bug or something?

Most important, is there some way to keep it return Object instead of String?

Any help will be appreciate!

Product Version: UE 4.13
more ▼

asked Sep 18 '16 at 12:52 PM in Bug Reports

avatar image

37 4 9 14

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

2 answers: sort voted first

I had the same problem and have tracked down the source. In JsonObjectConverter.cpp in the ConvertScalarUPropertyToJsonValue function, in the UStructProperty section, the Struct is first checked for HasExportTextItem(). If it doesn't then it is exported with UStructToJsonObject where the code that checks for FJsonObjectWrapper is located. The problem is that the FJsonObjectWrapper returns true on HasExportTextItem() so the UStructToJsonObject() function is never called for it.

A possible fix would be to disable the HasExportTextItem() check for FJsonObjectWrapper structs.

In my code I fixed this with a patch. I created a CustomExportCallback that checks to see if the property is a FJsonObjectWrapper and calls UStructToJsonObject if it is.

Here is the function that I used with the CustomExportCallback:

         TSharedPtr<FJsonValue> USampleClass::FJsonObjectWrapperFixer(
                 UProperty* property, 
                 const void* value)
             FString strPropertyType = property->GetCPPType();
             if (strPropertyType == "FJsonObjectWrapper")
                 TSharedRef<FJsonObject> outObject(new FJsonObject());
                 return TSharedPtr<FJsonValue>(new FJsonValueObject(outObject));
             return TSharedPtr<FJsonValue>(NULL);

more ▼

answered Feb 27 '17 at 09:06 AM

avatar image

Joey At Gateway
21 1

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

Hey Adcentury,

I am not sure what you are seeing but my FJsonObjectWrapper gives both a FString as "JsonString" and a TSharedPtr as "JsonObject". Here is a screenshot:

alt text

Can you please provide more information related to your issue?


491006_json.png (10.8 kB)
more ▼

answered Sep 19 '16 at 07:39 PM

avatar image

ImVawx ♦♦ STAFF
6.8k 114 17 127

(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