如何在Objective-C中解析以下JSON字符串

时间:2011-05-04 11:04:09

标签: iphone objective-c json ios4

我有以下格式的JSON字符串,需要在objective-c

中解析
[{"image":"<link_to_image>",
  "pic-number":"2862",
  "n-lines":5,
  "default":"[{"line_1":"one!"},
              {"line_2":"two"},
              {"line_3":"three"},
              {"line_4":"four"},
              {"line_5":"five"}]"
}, 
... ]

默认数组的长度可能因每个项目而异。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

刚刚找到问题的原因,

相反

  "default":**"**[{"line_1":"one!"},
              {"line_2":"two"},
              {"line_3":"three"},
              {"line_4":"four"},
              {"line_5":"five"}]**"**

JSON字符串应具有以下格式,否则解析将失败

  "default":[{"line_1":"one!"},
              {"line_2":"two"},
              {"line_3":"three"},
              {"line_4":"four"},
              {"line_5":"five"}]