Sign In Register

How can we help you today?

Start a new topic

Converting GSData to Json


I have this very newbie question about converting GSData to Json.

For testing, I made a simple class and converting into Json and set it under player script data.

I got this on my Unity Log:

GS: RECV:{"@class":".LogEventResponse","requestId":"636451268112022475_0","scriptData":{"player_Data":"{\"name\":\"Hello World\",\"level\":10}"}}

Now I want to retrieve it and what I have put is:


 But it returns null. How can I get the response in json format? So that i can convert back into my class.

P.S. I am using Unity.



1 Comment

 Hey Derek,

It looks like what you are ending back is a JSONstring rather than JSON, so you wont be able to access that JSON the way you want.
You can send the data back as a JSON object in Spark.setscriptData("player_Data", data);

There is some further info you can get to parse it into a class or struct in a tutorial here. Its probably a bit more than you need, but it should work for you.

Let me know if that works.

Login to post a comment