How do I handle multiple rows returned from my JSON server response? This could be N# of rows from an SQL Select statement - consider Inventory, abilities, loadout etc…
So far - i can only seem to get 1 return object to function with the FJsonSerializer::Deserialize(Reader, JsonObj).
I am getting an FHttpResponsePtr return - and doing: Response->GetContentAsString(); which is the only thing i can see as a possible way to handle JSON response from database from the web. Perhaps theres a better alternative? CODE:
TSharedPtr<FJsonObject> JsonObj = MakeShareable(new FJsonObject());
FString MsgBody = Response->GetContentAsString();
UE_LOG(LogTemp, Warning, TEXT("%s"), *MsgBody);
TSharedRef<TJsonReader<TCHAR>> Reader = TJsonReaderFactory<TCHAR>::Create(*MsgBody);
if (FJsonSerializer::Deserialize(Reader, JsonObj))
{
TSharedPtr<FJsonObject> AchObj = JsonObj->GetObjectField("Achievements");
UE_LOG(LogTemp, Warning, TEXT("JSON IS VALID"));
// All is okay, json is valid
FString ID = AchObj->GetStringField(TEXT("ID"));
FString TaskType = AchObj->GetStringField(TEXT("TaskType"));
FString ClassID = AchObj->GetStringField(TEXT("ClassID"));
FString Amount_Current = AchObj->GetStringField(TEXT("Amount_Current"));
FString Amount_Needed = AchObj->GetStringField(TEXT("Amount_Needed"));
UE_LOG(LogTemp, Warning, TEXT("%s %s %s %s %s"), *ID, *TaskType, *ClassID, *Amount_Current, *Amount_Needed);
}
JSON RESPONSE:
{“Achievements”:{“ID”:“0”,“TaskType”:“kill”,“ClassID”:“ClassStuffHere”,“Amount_Current”:“0”,“Amount_Needed”:“25”}}{“Achievements”:{“ID”:“1”,“TaskType”:“kill”,“ClassID”:“bears”,“Amount_Current”:“0”,“Amount_Needed”:“50”}}