question

Dylan Hunt avatar image
Dylan Hunt asked

[RESOLVED] Getting a gnarly SimpleJSON can't parse - error when attempting to ExecuteCloudScript from client (Unity)

SimpleJSON err for cloud script exec:

Sorry hard to see -- I'll dig through logs soon and find a clearer version to replace, if need.

Just seeing if you know a general answer before I post details, I'm just running out the door and will come back to edit with more details.

EDIT: I pass an object "EndInfo" that contains the following:

//     public string name;
//     public string username;
//     public string startClass;
//     public Classes.Faction startFaction;
//     public string finalClass;
//     public Classes.Faction finalFaction;
//     public bool won;

essentially a string, string, enum (string), string, enum (string), and bool.

EDIT 2: Works fine with postman. Now I really am wondering if I need to make a separate object just to ToString() those enums. I figured SimpleJSON would do that. This is still my latest theory.

EDIT 3: I tried some mock values within Unity - and seemed to oddly work fine:

// Works
EndInfo.playerInfo mockPlayerInfo = new EndInfo.playerInfo();
mockPlayerInfo.name = "Test Name";
mockPlayerInfo.username = "TestUsername";
mockPlayerInfo.startClass = "Observer";
mockPlayerInfo.startFaction = Classes.Faction.BlueDragon;
mockPlayerInfo.finalClass = "Nightwatch";
mockPlayerInfo.finalFaction = Classes.Faction.BlackRose;
mockPlayerInfo.won = true;

I realized I didn't do any null checks. However, a null value shouldn't effect a SimpleJSON parse, should it? if name = null, for example. It should just do "name": ""

CloudScript
errjson.png (149.3 KiB)
3 comments
10 |1200

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

brendan avatar image brendan commented ·

Sorry, I think we'll need a copy/paste of the actual error, as well as the details of the response from the ExecuteCloudScript call.

0 Likes 0 ·
Dylan Hunt avatar image Dylan Hunt brendan commented ·

I'll see what I can do. I'll try a few more mock situations first to ensure I didn't do anything stupid :P

0 Likes 0 ·
Dylan Hunt avatar image Dylan Hunt brendan commented ·

Here we go (working on a cloud response soon):

[0x000c6] in C:\....\Assets\PlayFabSdk\Shared\Internal\SimpleJson.cs:1049 
  at PlayFab.Json.PlayFabSimpleJson.SerializeValue (IJsonSerializerStrategy jsonSerializerStrategy, System.object.Value, System.Text.StringBuilder


[0x0017c] in C:\....\Assets\PlayFabSDK\Shared\Internal\SimpleJson.cs:1072
  at PlayFab.Json.PlayFabSimpleJson.SerializeObject (IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values.
  System.Text.StringBuilder builder)


[0x00087] in C:\....\Assets\PlayFabSdk\Shared\Internal\SimpleJson.cs:1098
  at PlayFab.Json.PlayFabSimpleJson.SerializeValue (IJsonSerializerStrategy jsonSerializerStrategy, System.Object.Value, System.Text.StringBuilder
  builder)<br>
0 Likes 0 ·

1 Answer

·
Dylan Hunt avatar image
Dylan Hunt answered

Resolved -- I thought this was BEFORE sending to PF, but it was actually both during and after --

This happens when I tried to parse the result into the object that should have returned. Instead, I had a null value.

So this was a tricky 2-part error:

1) I was returning null from CloudScript -- however, returning "successfully"

2) I tried to parse null into an object. Fail (resulting in the nasty errors above)

:)

10 |1200

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

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.