字符串反序列化到JSON-Array,JSON-Object序列化到字符串
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(JsonListStr);
TArray<TSharedPtr<FJsonValue>> InArray;
if (FJsonSerializer::Deserialize(JsonReader, InArray))
{
for(const auto& iter : InArray)
{
const auto& jsonObject = iter->AsObject().ToSharedRef();
FString Out;
TSharedRef<TJsonWriter<>> JsonWriter = TJsonWriterFactory<>::Create(&Out);
if (!FJsonSerializer::Serialize(jsonObject, JsonWriter))
{
UKismetSystemLibrary::PrintString(GetWorld(), TEXT("GetAllLuts::FJsonSerializer::Serialize Failed!"));
return false;
}
LutParams.Add(Out);
}
}
else
{
UKismetSystemLibrary::PrintString(GetWorld(), TEXT("GetAllLuts::FJsonSerializer::Deserialize Failed!"));
return false;
}