Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Hudfire on October 23, 2015, 06:29:46 PM

Title: Help with Strings [SOLVED]
Post by: Hudfire on October 23, 2015, 06:29:46 PM
I am creating an app for Android and hopefully for iOS as well where I am using Unity to send commands to a Particle Photon device. I can send the commands to it by using the WWWPOST Mobile action. It works great and is doing what I need it to do. However, I am having a problem with trying to figure out how to parse information from a returned string.

The following string is returned after sending the command:

{
  "id": "xxxxxxxxxxxxxxxxxxxxxxxxx",
  "last_app": "",
  "connected": true,
  "return_value": 1
}

My question is, how would I pull the information for the "return_value": and save it to a variable? In the above example, I would need to save the '1' as an int variable. That number changes depending on which command I send, and would like to be able to check what state the device is in.

Any help on this issue would be greatly appreciated.

Thanks!
Dave
Title: Re: Help with Strings
Post by: Hudfire on October 28, 2015, 10:29:53 AM
Bump!

Still banging my head against my desk  ;)
Title: Re: Help with Strings
Post by: jeanfabre on October 28, 2015, 11:27:27 AM
Hi,

 this is a json string, and so you should use some custom actions for this.

I have created a framework that handles Xml and json, called DataMaker (https://hutonggames.fogbugz.com/default.asp?W1133).

There is an action called "JsonGetObjectProperties" which will save properties of a single json object in fsm variables.

Bye,

 Jean
Title: Re: Help with Strings
Post by: Hudfire on October 28, 2015, 07:35:28 PM
Thank you very much for this Jean. I will look into it and let you know how it works out.
Title: Re: Help with Strings
Post by: Hudfire on October 28, 2015, 07:45:24 PM
Jean, you rock brother!!! This works perfectly. Thank you so much!