I’m writing a class to save and read a structure from a file. I’m using the “JsonUtilities” module. Version of my UE: 4.26.2. Saving the structure to a file works correctly, but when I try to use the deserialization method, the compiler throws a bunch of strange errors. For example, here’s the struct I’m using and trying to load data into:
USTRUCT(BlueprintType)
struct FStorageUserData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite)
int32 Id;
UPROPERTY(BlueprintReadWrite)
FString Name;
UPROPERTY(BlueprintReadWrite)
FString Password;
};
The method for loading data from file:
bool UFileManager::GetUser(FStorageUserData& UserData)
{
const FString Path = FPaths::ProjectDir() + "Users.json";
FString JsonString;
if (!FFileHelper::LoadFileToString(JsonString, *Path))
{
Log(XXI_Service::Error, "Failed to load the file:" + Path);
return false;
}
FJsonObjectConverter::JsonObjectStringToUStruct(JsonString, &UserData, 0, 0);
return true;
}
The compiler does not throw any errors. I checked every line of the method and found out that the compiler crashes on the call JsonObjectStringToUStruct (penultimate line).
I tried to copy the code directly from it, and my further attempts showed that the problem is in the method FJsonSerializer::Deserialize, to be even more specific - MakeShared and other places.
I’ve attached a screenshot with the errors I’m getting but can’t figure out due to unreadable compiler coding. I just want to know if this problem is just me or is it a bug in the engine module of a particular version?