FJsonSerializer::Deserialize(reader, JsonObj) - fails every time

Hello all - been over a MULTITUDE of answerhub posts and wiki docs to try to get JSON deserialization happening on my end… with no luck. Below is my code, it always fails the Deserialize() function. All headers are included properly - this is purely the ability to load a JSON object and read from it - which i cant get working :frowning: My output is coming from a PHP file i built - shown below as well.

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))
{
	UE_LOG(LogTemp, Warning, TEXT("JSON IS VALID"));
	// All is okay, json is valid
	//TSharedPtr<FJsonObject> jsonObj = JsonObj->GetObjectField("array");
	UE_LOG(LogTemp, Warning, TEXT("ARRAY SIZE FOR ARRAYFIELD: %s"), JsonObj->GetArrayField("AchievementResults").Num());
	//TArray<TSharedPtr<FJsonValue>> OutArray = JsonObj->GetArrayField("AchievementResults");
	//for (int32 i = 0; i < OutArray.Num(); i++)
	//{
	//	UE_LOG(LogTemp, Warning, TEXT("%s"), *OutArray[i]->AsString());
	//}
	
}
else UE_LOG(LogTemp, Error, TEXT("Unable to read JSON Data"));

PHP JSON OUTPUT FROM WEB:

{“Status”:“1”,“AchievementResults”:{“ID”:“0”,“TaskType”:“kill”,“ClassID”:“ClassStuffHere”,“Amount_Current”:“0”,“Amount_Needed”:“25”}}

Hey your code seems to be correct but check the Response code this might help you for better debugging your issue and 1st try to get the simple fields like Status…!! Here is the sample code i used for debugging in my project

void AJsonDownloader::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
	if (bWasSuccessful)
	{	
		TSharedPtr<FJsonObject> JsonParsed;
		TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(Response->GetContentAsString());
		if (FJsonSerializer::Deserialize(JsonReader, JsonParsed))
		{
			FString Status= JsonParsed->GetStringField("Status");	
	         }
	if (!Response.IsValid()) {
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Invalid Http Response..!!")));
		UE_LOG(LogTemp, Warning, TEXT("Invalid Http Response..!!"));
	}
	else if (Response->GetResponseCode() == 200) {
		FString msg = Response->GetContentAsString();
		
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT(" Valid Http Response.. %s"), *msg));
		UE_LOG(LogTemp, Warning, TEXT("%s"), *msg);
	}
	else {
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Error code %d"), Response->GetResponseCode()));
		UE_LOG(LogTemp, Warning, TEXT("%d"), Response->GetResponseCode());
	}

This acutally turned out to be a RETURN OBJECT problem - i was returning more than 1 row in my JSON response… which i’ll have to learn to deal with in a few - but the code worked fine when i only returned 1 row instead of many.

As for the multiple rows response - i’m trying to FString::ParseIntoArray(&OutArray, Delims, false)… but keep the delimiters… anyone know how to do this?