bool FJsonObjectConverter::UStructToJsonObjectString(const UStruct* StructDefinition, const void* Struct, FString& OutJsonString, int64 CheckFlags, int64 SkipFlags, int32 Indent, const CustomExportCallback* ExportCb, bool bPrettyPrint) { TSharedRef<FJsonObject> JsonObject = MakeShareable( new FJsonObject() ); if (UStructToJsonObject(StructDefinition, Struct, JsonObject, CheckFlags, SkipFlags, ExportCb)) { bool bSuccess = false; if (bPrettyPrint) { bSuccess = UStructToJsonObjectStringInternal<TCHAR, TPrettyJsonPrintPolicy<TCHAR> >(JsonObject, OutJsonString, Indent); } else { bSuccess = UStructToJsonObjectStringInternal<TCHAR, TCondensedJsonPrintPolicy<TCHAR> >(JsonObject, OutJsonString, Indent); } if (bSuccess) { return true; } else { UE_LOG(LogJson, Warning, TEXT("UStructToJsonObjectString - Unable to write out json")); } } return false; }
bool FJsonObjectConverter::UStructToJsonObjectString(const UStruct* StructDefinition, const void* Struct, FString& OutJsonString, int64 CheckFlags, int64 SkipFlags, int32 Indent) { TSharedRef<FJsonObject> JsonObject = MakeShareable( new FJsonObject() ); if (UStructToJsonObject(StructDefinition, Struct, JsonObject, CheckFlags, SkipFlags)) { TSharedRef<TJsonWriter<> > JsonWriter = TJsonWriterFactory<>::Create(&OutJsonString, Indent); if (FJsonSerializer::Serialize( JsonObject, JsonWriter )) { JsonWriter->Close(); return true; } else { UE_LOG(LogJson, Warning, TEXT("UStructToJsonObjectString - Unable to write out json")); JsonWriter->Close(); } } return false; }