0

我需要找出stackoverflowid的值在哪里。怎么做?

{
 "kind": "blogList",
 "items": [
  {
   "kind": "blog",
   "id": "stackoverflow",
   "selfLink": "https://example.com",
   "posts": {
    "totalItems": 0,
    "selfLink": "https://www.foo.bar"
   },
   "pages": {
    "totalItems": 0,
    "selfLink": "https://www.example.com"
   },
   "locale": {
    "language": "en",
    "country": "",
    "variant": ""
   }
  },
  {
   "id": "google",
   "selfLink": "https://www.foo.bar",
   "posts": {
    "totalItems": 0,
    "selfLink": "https://www.test.com"
   },
   "pages": {
    "totalItems": 0,
    "selfLink": "https://www.example.com"
   },
   "locale": {
    "language": "en",
    "country": "",
    "variant": ""
   }
  },

对不起我的英语不好。

4

1 回答 1

1

试试这个代码,这将作为一个有用的例子(它完美地工作)(之前下载这个):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import mx.utils.ArrayUtil;
            import mx.controls.Alert;
            import lib.JSON;
            private var jsonString:String = '{"root":[{"id":"val1"},{"id":"val2"}]}';

            public function init():void{
                var decodedObj:Object = JSON.decode(jsonString);
                Alert.show(decodedObj["root"][0].id); //prints val1
                Alert.show(ArrayUtil.toArray(decodedObj["root"])[1].id); //prints val2
            }
        ]]>
    </mx:Script>
</mx:Application>
于 2013-06-24T14:45:35.783 回答