In the XPLatCppWindows SDK, you specify the JSON for cloud scripts as:
Json::Value param; param["blah"] = "blah_too";
and then pass that into the execute cloud script request function parameter.
In the Unreal PlayFab Plugin implementation the FunctionParameter for FExecuteCloudScriptRequest
is of type: FJsonKeeper
How do I use this FJsonKeeper object? Especially for multiple variables in the JSON.
Answer by Sarah Zhang · Oct 21, 2020 at 08:44 AM
You can try to refer to our testing code in the UnrealMarketplacePlugin GitHub repository. You can find the corresponding code on this page, especially on line 84.
... outerWrapper->SetArrayField(TEXT("testReport"), TestSuiteList); auto functionParameter = PlayFab::FJsonKeeper(); functionParameter.readFromValue(MakeShareable(new FJsonValueObject(outerWrapper))); PlayFab::ClientModels::FExecuteCloudScriptRequest request; request.FunctionName = TEXT("SaveTestData"); request.FunctionParameter = functionParameter; request.GeneratePlayStreamEvent = true; ...
Are there any examples on how to read the JSON from a FExecuteCloudScriptResult ?
Nevermind, I figured it out:
auto funcResult = result.FunctionResult.GetJsonValue()->AsObject(); auto message = funcResult.Get(); FString messageVal; message->Values["messageValue"]->TryGetString(messageVal);