How to add an Array of Json Objects to a Json Object?

// create Json values array

TArray< TSharedPtr<FJsonValue> > ObjArray;

// create a Json object and add a string field

TSharedPtr< FJsonObject > JsonObj = MakeShareable(new FJsonObject);

JsonObj->SetStringField(“Abc”, “AbcValue”);

// create a Json value object to hold your Json object

TSharedRef< FJsonValueObject > JsonValue = MakeShareable( new FJsonValueObject( JsonObj) );

// add the object to the array

ObjArray.Add(JsonValue);

// THIS should work

AnotherJsonObj->SetArrayField(“array”, ObjArray);

Modifications for your code to build in bold

6 Likes