Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JSON - Adobe ActionScript® 3 (AS3 ) API Reference

Explorer ,
Aug 23, 2012 Aug 23, 2012

This question was posted in response to the following article: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/JSON.html

TOPICS
ActionScript
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 23, 2012 Aug 23, 2012

what is wrong with this page? It does not show in the Top Level package. Where are methods? Errors?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 23, 2012 Aug 23, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 23, 2012 Aug 23, 2012

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2013 Feb 16, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 17, 2013 Feb 17, 2013

@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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2013 Jan 27, 2013

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)

        }

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2013 Mar 06, 2013
LATEST

How to make stringify() returns unicode escape sequences(like \uxxx) rather than native unicode characters?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines