Hi,

I'm having a difficult time pulling data out of some JSON I'm currently working with. The following script is something that I found online using Adobe's corelib to parse the JSON, but the sample JSON the guy used was really basic. The one I'm working with has a few levels. For example, how would I pull out the "date_created"? I've tried calling it with dot syntax but I keep getting errors. Can someone shed some light on this for me? Thank you in advance... Cheers!

The script I'm using with corelib:

import com.adobe.serialization.json.JSON;
var loader:URLLoader = new URLLoader() ;
var request:URLRequest = new URLRequest() ;
request.url = "someJSON_URL" ;
loader.load(request) ;
loader.addEventListener(Event.COMPLETE, decodeJSON) ;

function decodeJSON(event:Event):void {
        var loader:URLLoader = URLLoader(event.target);
        var evData:Array = JSON.decode("["+loader.data+"]");
        myFlashVars.appendText("\n" + String(evData[0].xml));
        for (var key:Object in evData) {
                myFlashVars.appendText("\n" + "\n" + String(evData[key]));
        }
}

============================================

My JSON looks like this:

{
  "xml": {
    "device": {
      "view": {
        "action": "getsummary",
        "device": {
          "date_created": "2/28/2009 2:59:24 PM",
          "date_modified": "2/28/2009 2:59:24 PM",
          "device_id": "9999999999999999999999999999",
          "device_status": "active",
          "device_type": "other",
          "friendly_name": "Foo",
          "make": "Bar",
          "model": "999",
          "serial_number": "Test Serial No"
        },
        "error": {
          "code": 0,
          "message": ""
        },
        "owner": {
          "guid": "99999999999999999999999999",
          "partner_id": 0
        }
      }
    },
    "session": {
      "class": "Device",
      "first_name": "Frank",
      "guid": "S99999999999999999999999",
      "language": "en-us",
      "last_name": "Zappa",
      "partner_id": 0,
      "proc": "View",
      "valid": 1
    }
  }
}


THANKS!!!
--
Carl Welch
http://www.carlwelch.com
http://blog.jointjam.com
[email protected]
805.403.4819

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to