0

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.

PaulB
  • 111
  • 2
  • 13
  • 1
    Did you add the library in linker dependencies or with #pragma comment(lib,"somejson.lib") ? – Michael Chourdakis Apr 05 '19 at 15:23
  • FJsonSerializer is part of the unreal engine libraries and should be included in the engine setup I think. Is that not the case? @MichaelChourdakis – PaulB Apr 05 '19 at 15:51
  • @MichaelChourdakis It turned out that I needed to add "Json" to the private dependency module names list. Thanks for the advice. – PaulB Apr 05 '19 at 18:00

0 Answers0