Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Dylan Hunt · Apr 05, 2017 at 02:00 AM · CloudScript

[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": ""

errjson.png (152.9 kB)
Comment

People who like this

0 Show 3
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brendan ♦♦ · Apr 05, 2017 at 02:35 AM 0
Share

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.

avatar image Dylan Hunt Brendan ♦♦ · Apr 05, 2017 at 02:45 AM 0
Share

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

avatar image Dylan Hunt Brendan ♦♦ · Apr 05, 2017 at 03:00 AM 0
Share

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>

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Dylan Hunt · Apr 05, 2017 at 08:57 AM

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)

:)

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    ExecuteCloudScriptServerRequest and Player ID 1 Answer

    Is there a way to get Limited Edition Count Available from server or client API? 1 Answer

    http.request POST request from CloudScript not working 1 Answer

    How can I convert Zulu time to UTC? 1 Answer

    Playfab cloudcripts Wondering 2 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges