I am trying to Deserialize Json using FJsonSerializer in Unreal engine 4 but am getting an unresolved external symbol error LNK2019. I understand what LNK2019 is but in this situation I don't see what would be causing it.
This code is placed inside an EdModeTookit for my editor plugin.
My Code
//JSON object for test
FString JsonString = "{'word': 'hello'}";
//JSON object to hold result
TSharedPtr<FJsonObject> JsonObject;
//JSON reader
const TSharedRef<TJsonReader<TCHAR>> Reader = TJsonReaderFactory<TCHAR>::Create(JsonString);
//Deserialize
if (FJsonSerializer::Deserialize(Reader, JsonObject)) {
UE_LOG(LogTemp, Log, TEXT("Deserialized JSON"));
}
When I compile I get 38 LNK2019 unresolved symbol errors. Here are the first 3
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl FJsonValueString::FJsonValueString(class FString const &)" (__imp_??0FJsonValueString@@QEAA@AEBVFString@@@Z) referenced in function "private: static bool __cdecl FJsonSerializer::Deserialize(class TSharedRef,0> const &,struct FJsonSerializer::StackState &)" (??$Deserialize@_W@FJsonSerializer@@CA_NAEBV?$TSharedRef@V?$TJsonReader@_W@@$0A@@@AEAUStackState@0@@Z) BayArea_I45 D:\Doccuments\Unreal Projects\BayArea_I45\Intermediate\ProjectFiles\Module.TrafficSim.cpp.obj 1
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: virtual __cdecl FJsonValueString::~FJsonValueString(void)" (__imp_??1FJsonValueString@@UEAA@XZ) referenced in function "public: virtual void * __cdecl FJsonValueString::`scalar deleting destructor'(unsigned int)" (??_GFJsonValueString@@UEAAPEAXI@Z) BayArea_I45 D:\Doccuments\Unreal Projects\BayArea_I45\Intermediate\ProjectFiles\Module.TrafficSim.cpp.obj 1
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl FJsonValueNumber::FJsonValueNumber(double)" (__imp_??0FJsonValueNumber@@QEAA@N@Z) referenced in function "private: static bool __cdecl FJsonSerializer::Deserialize(class TSharedRef,0> const &,struct FJsonSerializer::StackState &)" (??$Deserialize@_W@FJsonSerializer@@CA_NAEBV?$TSharedRef@V?$TJsonReader@_W@@$0A@@@AEAUStackState@0@@Z) BayArea_I45 D:\Doccuments\Unreal Projects\BayArea_I45\Intermediate\ProjectFiles\Module.TrafficSim.cpp.obj 1
I really don't know why I am getting errors since this code seems to match the documentation and I have seen others claiming to have used similar code successfully.