发现一个新的json解析器,JSwoof.
官网:
http://www.waynemike.co.uk/jswoof
例子:Decoder
例子:Encoder
官网:
http://www.waynemike.co.uk/jswoof
例子:Decoder
var simpleJSON:String = "{\"name\":\"wayne\",\"value\":1000.0}"; var jObj:Object = JParser.decode(simpleJSON); if(jObj == null) { var errObj:Object = JParser.getLastError(); Alert.show(errObj.errorStr); }
例子:Encoder
var jsonObj:Object = new Object(); var jsonArr:Array = new Array(); /* Build up a simple object. */ for(var loop:int = 0; loop < 10; loop++) { var currObj:Object = new Object(); currObj.name = "name " + loop.toString(); currObj.value = loop.toString(); jsonArr.push(currObj); } jsonObj.description = "a simple encoding test"; jsonObj.array = jsonArr; /* Encoder the object into JSON. */ var jsonStr:String = JParser.encode(jsonObj);