Hey guys! I really need some help here before I decide that the UE can rot in hell…
Basically, I am trying to turn FString (JSON data) into custom UStruct. Should be very simple thing to do, right? Wrong.
I’m not new to UE and C++ so the first thing I did was to look up for the relevant modules: Json and JsonUtilities. NOTE: EU5 doesn’t seem to be using public and private dependencies in target files but instead ExtraModuleNames.
Next, I added a FunctionLibrary and my first function:
UFUNCTION(BlueprintCallable)
static void ConvertJSONToPlayerData(const FString& in_json);
Now the actual meat of the code. I had to search for some help for this and internet didn’t fail:
#include "DataFunctionLibrary.h"
#include "Json.h"
#include "JsonUtilities.h"
void UDataFunctionLibrary::ConvertJSONToPlayerData(const FString& in_json)
{
TSharedPtr<FJsonObject> rootData;
TSharedRef<TJsonReader<>> reader = TJsonReaderFactory<>::Create(in_json);
FJsonSerializer::Deserialize(reader, rootData);
}
This doesn’t actually convert the JSON into UStruct, I know. But this should do a simple deserialization. HOWEVER! I get LNK2019 error which suggests that either there is a dependency/library missing or I have mistake somewhere that I cannot see.
I’m reaching out to you guys because this is driving me crazy. I have tried almost everything. The code compiles up to line: FJsonSerializer::Deserialize
The actual function (FJsonObjectConverter::JsonObjectStringToUStruct) to convert JSON into UStruct gives same LNK2019 error, which is why I am trying to work up from basics.
SOLVED:
Well, this is embarrassing. I had been staring at wrong file for the dependencies.
Note for yourself: Target file != Build file
Excuse me while I go to hide under the table.