kbailey avatar image
kbailey asked

Is the UE4 struct FPlayFabBaseModel missing PLAYFAB_API macro?

While messing around with the UE4 c++ sdk I came across a linker error when calling the FPlayFabBaseModel::toJSONString function.

The error is:

LoginActor.cpp.obj : error LNK2019: unresolved external symbol "public: class FString __cdecl PlayFab::FPlayFabBaseModel::toJSONString(void)const " (?toJSONString@FPlayFabBaseModel@PlayFab@@QEBA?AVFString@@XZ) referenced in function "private: void __cdecl ALoginActor::OnCloudFunctionSuccess(struct PlayFab::ClientModels::FExecuteCloudScriptResult const &)" (?OnCloudFunctionSuccess@ALoginActor@@AEAAXAEBUFExecuteCloudScriptResult@ClientModels@PlayFab@@@Z)

I believe the fix is to replace:

struct FPlayFabBaseModel


struct PLAYFAB_API FPlayFabBaseModel

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

1807605288 avatar image
1807605288 answered

You're not wrong, and your fix may be adopted.

Before I accept your suggestion blindly though:
Why are you calling toJSONString for a FPlayFabBaseModel? FPlayFabBaseModel has no attributes, and so the output json will be equivalent to empty object.

If you're trying to re-serialize FExecuteCloudScriptResult, I don't think it will work the way you hope, because that object doesn't have a static definition.

I could be mis-remembering that code, but I don't think it's designed to output the json for objects without a static definition.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

kbailey avatar image kbailey commented ·

I was calling it on various F*Result objects to have it spit out some JSON that represented the result. I'm just testing this stuff out seeing what I get, nothing special. In this case it was the FExecuteCloudScriptResult::FunctionResult object and again, just wanted to print out whatever data was in there. If there's a better way, I'll gladly head toward that!

And thank you for the swift reply. I appreciate it!

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ kbailey commented ·

See Montana Tuska's answer below.

Unfortunately, in C++ we can't as easily just print arbitrary json outputs like the CloudScript FunctionResult. You can evaluate it like MT says below, and output anything you are expecting to find in your result.

0 Likes 0 ·
Montana Tuska avatar image Montana Tuska commented ·

You should not need to use that toJSONString function, especially since you're talking about the FExecuteCloudScriptResult::FunctionResult. FunctionResult is a FJsonKeeper type. Instead, you should use the FJsonKeeper::GetJsonValue then use the ue4 FJsonValue functions from there. You will most likely want to do something like FunctionResult.GetJsonValue()->AsObject() then use the FJsonObject methods instead.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.