JSON - Adobe ActionScript® 3 (AS3 ) API Reference
Copy link to clipboard
Copied
This question was posted in response to the following article: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/JSON.html
Copy link to clipboard
Copied
what is wrong with this page? It does not show in the Top Level package. Where are methods? Errors?
Copy link to clipboard
Copied
If you don't see anything on a page, it's usually because of filter settings.
In Packages and class filters, towards the top of the page, for Runtimes, be sure you have selected AIR 3.4 and earlier and Flash Player 11.4 and earlier
HTH
Randy Nielsen
SeniorContent and Community Manager
Adobe
Copy link to clipboard
Copied
It's little bit (a lot) confusing but yes, that was the problem. You should think of improving the usability.
Another question: parse method does not throw an error is the text string is not valid JSON representation?
Copy link to clipboard
Copied
There is a problem. When the selected Runtime Filters are set to AIR 3.5 and Flash Player 11.5 or AIR 3.4 and Flash Player 11.4, JSON does not show up in Top Level packages. JSON only becomes listed with the (currently) latest Runtime of AIR 3.6 and Flash Player 11.6 is selected.
Copy link to clipboard
Copied
@The DarkIn1978.
Yep. I can reproduce this. I'll ask someone to look into it.
Thanks for the tip!
Randy Nielsen
Senior Content and Community Manager
Adobe

Copy link to clipboard
Copied
Here is very simple example of importing a json file named "fruits.js". This example has the text for the imported file followed by the actionscript package coding...
// Content for js file named "fruits.js"…
{
"fruits":
[
{
"fruit":"Apple",
"fruitcolor":"Red"
},
{
"fruit":"Banana",
"fruitcolor":"Yellow"
},
{
"fruit":"Grapes",
"fruitcolor":"Purple"
}
]
}
// AS3 code to import and parse the file…
package {
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
public class AddJson extends Sprite {
public var loader:URLLoader = new URLLoader();
public function AddJson() {
//loader set-up
var request:URLRequest = new URLRequest("fruits.js");
loader.load(request);
loader.addEventListener(Event.COMPLETE, jsonLoaded);
}
public function jsonLoaded(event:Event):void {
var jsonContent:URLLoader = URLLoader(event.target);
//json
var data:Object = JSON.parse(jsonContent.data);
trace(data.fruits.length);
trace("The first one is " + data.fruits[0].fruit + " : " + data.fruits[0].fruitcolor);
var secondFruit:String = data.fruits[1].fruit;
trace("secondFruit as string data: " + secondFruit)
}
}
}
Copy link to clipboard
Copied
How to make stringify() returns unicode escape sequences(like \uxxx) rather than native unicode characters?

