I’m quite new to c++ in Unreal 4 and I’m currently getting JSON trough REST. I have the response from server but the problem is to go get values properly from json. One thing which confuses me is JsonObject. So how to initialize it properly? How can I set my JSON response to JsonObject and how to get values out of it?
I’m trying out something like this.
MessageBody = Response->GetContentAsString();
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
TSharedRef< TJsonReader<> > JsonReader = TJsonReaderFactory<>::Create(*MessageBody);
if (FJsonSerializer::Deserialize(JsonReader, JsonObject) &&
JsonObject.IsValid())
{
TArray<TSharedPtr<FJsonValue>> objArray = JsonObject->GetArrayField(TEXT("rows"));
for (int32 i = 0; i < objArray.Num(); i++)
{
TSharedPtr<FJsonValue> value = objArray*;
TSharedPtr<FJsonObject> json = value->AsObject();
FString name = json->GetStringField(TEXT("51205"));
}