How to parse json array?

Hi,

This question is still unanswered, thyshimrod’s solution assumes nested array and the OP asks about the root array.

Here’s what you should do, I believe:

FString rawJson = "[\"qwe\", 12, \"3345\", 0, 0.4]";
TSharedPtr<FJsonValue> jsonParsed;

TSharedRef<TJsonReader<TCHAR>> jsonReader = TJsonReaderFactory<TCHAR>::Create(rawJson);

if (FJsonSerializer::Deserialize(jsonReader, jsonParsed))
{
    TSharedPtr<FJsonObject> firstObject = jsonParsed->AsArray()[0]->AsObject();
    // ...
}

Please note that instead of FJsonObject a more generic class FJsonValue is used, which may be converted to an array or other objects.

1 Like