/customers/iconara.net/iconara.net/httpd.www/blog/wp-content/plugins/wp-super-cache/wp-cache-phase1.php Iconara » Parsing JSON using ExternalInterface

Parsing JSON using ExternalInterface

I wrote about this in my last post, but I thought it important enough to give it it’s own post:

var json : String =
    "{a: 1, b: 'hello world', c: [1, 3, 4, 5]}";

var o : Object = ExternalInterface.call("function(){return " + json + ";"}");

The variable o should now contain an object representation of the string json.

Disclaimers: this is most likely very slow, and it is by no means secure. The same caveats as using JavaScript’s eval function applies. If you recieve JSON from an untrusted source, don’t do this.

Leave a Reply