纠结了大半天才整明白com.adobe.serialization.json.JSON.decode和com.adobe.serialization.json.JSONDecoder的转换字符串格式,
字符串类型分四种情况,下边代码注释为 0 、1、2、3及对应每种情况的输出
下边贴些整理后的代码
private function searchByText():void
{
// var s:String = '[{"tab":"aaa"}]'; ? ? ? ? ? ? ? ? ? ? ?//0
// var s:String = '[{"tab":"aaa"},{"tab":"aaa"}]'; ? ? ? ? ? ? ?//1
var s:String = '[{"wai":[{"tab":"aaa"},{"tab":"aaa"}]}]'; ? ? ? ? ? ?//2
// var s:String = '[{"tab1":"aaa1"},{"wai":[{"tab":"aaa"},{"tab":"aaa"}]}]'; ? ? ? ? ? ?//3 //var orderGrid:ArrayCollection=new ArrayCollection(com.adobe.serialization.json.JSON.decode(s) as Array); standMsg = com.adobe.serialization.json.JSON.decode(s); //trace(standMsg.tab); ? ? ? ? ? ? ? ? ? ? ? ?//0 ? ? ?输出: aaa //trace(standMsg[0].tab); ? ? ? ? ? ? ? ? ? ?//1 ? ???输出:aaa trace(standMsg[0].wai[0].tab); ? ? ? ?//2 ? ??输出:?aaa //trace(standMsg[0].tab1); ? ? ? ? ? ? ? ? ?//3 ???输出:aaa1 //trace(standMsg[1].wai[1].tab); ? ? ? ? //3 ? ?输出:aaa var jsonObj:Object=new JSONDecoder(s); //jsonObj.propertyIsEnumerable(); //jsonObj.valueOf(); //var ss:String = jsonObj.getValue(); standMsg=jsonObj.getValue() as Array; trace(standMsg); }