2010-07-03 88 views
0

我目前使用JSON框架,並需要一些幫助,雖然解析我從我的服務器獲取的一些JSON。以下是JSON的外觀: 就像我說過的,我已經安裝了json-framework,但我無法弄清楚如何實際解析它。有人可以告訴我嗎?謝謝!需要幫助使用JSON框架解析iPhone上的JSON

[ 
    { 
    "id":"0", 
    "name":"name", 
    "info":"This is info", 
    "tags": 
     [ 
      { 
      "id":"36", 
      "tag":"test tag", 
      }, 
      { 
      "id":"37", 
      "tag":" tag 2", 
      } 
     ], 
    "other":"nil" 
    }, 
    { 
    "id":"1", 
    "name":"name", 
    "info":"This is info", 
    "tags": 
     [ 
      { 
      "id":"36", 
      "tag":"test tag", 
      }, 
      { 
      "id":"37", 
      "tag":" tag 2", 
      } 
     ], 
    "other":"nil" 
    } 
] 

回答

0

jsonlint.com會幫助你至於驗證,我不相信你想要結尾的逗號。 json-framework實現了一個嚴格的解析器。

[ 
{ 
    "id": "0", 
    "name": "name", 
    "info": "This is info", 
    "tags": [ 
     { 
      "id": "36", 
      "tag": "test tag" 
     }, 
     { 
      "id": "37", 
      "tag": " tag 2" 
     } 
    ], 
    "other": "nil" 
}, 
{ 
    "id": "1", 
    "name": "name", 
    "info": "This is info", 
    "tags": [ 
     { 
      "id": "36", 
      "tag": "test tag" 
     }, 
     { 
      "id": "37", 
      "tag": " tag 2" 
     } 
    ], 
    "other": "nil" 
} 
] 
0

查看json-framework下載中的Examples.m文件。也可用here。 該API可用here

您可能最終會在分析時使用NSString和NSObject類別。