Page 1 of 1
JSON.decode in extension
Posted: 23 Dec 2016, 18:37
by Motimot
Hello, my question is simple: How to use JSON.decode in AS extension?
I tried to import JSON, but it was unsuccessful, and I tried to google the solution but I haven't find anything.
So, I have a json text, how can i decode it to use it in the response?
Re: JSON.decode in extension
Posted: 26 Dec 2016, 08:47
by Lapo
Hi,
I am not sure I fully understand. Can you please specify which SFS version you're using?
Also are you loading the JSON from a file?
Back to your question, JSON support is included in AS3 since Flash Player 11:
http://help.adobe.com/en_US/FlashPlatfo ... /JSON.html
cheers
Re: JSON.decode in extension
Posted: 28 Dec 2016, 06:57
by Motimot
I'm using sfs pro.
I want to load json file from url, in an extension that was written in AS.
How to do this?
Re: JSON.decode in extension
Posted: 28 Dec 2016, 09:43
by Lapo
You could use the LoadVars class:
http://smartfoxserver.com/docs/1x/docPa ... /index.htm
(see under left menu, under "Other methods")
This emulates the LoadVars used in Flash and requires variables to be passed as a query string. In other words your webpage should return the JSON like this:
Code: Select all
json={ .... }&otherParam=123&nextParam=abc
If the web server returns pure JSON output then this won't work and you will have to integrate a java library to perform the HTTP call.
My suggestion is to use this:
http://hc.apache.org/httpclient-3.x/
Hope it helps