【发布时间】:2016-11-07 16:24:35
【问题描述】:
我有一个 API 端点,它以以下格式返回 JSON:
[
{
"id": "1",
"name": "John"
},
{
"id": "2",
"name": "Jane"
},
{
"id": "3",
"name": "Nick"
}
]
我试图在 Swift 3 中解析它,但我只能找到解析 JSON 格式的示例:
{
"blogs": [
{
"needspassword": true,
"id": 73,
"url": "http://remote.bloxus.com/",
"name": "Bloxus test"
},
{
"needspassword": false,
"id": 74,
"url": "http://flickrtest1.userland.com/",
"name": "Manila Test"
}
],
"stat": "ok"
}
,比我的要高出一个层次。
所以,我见过的例子只是简单地解析他们的数据,比如jsonResponse["blogs"],我不能这样做,因为我的格式不同。
我怎样才能解析我得到的格式,或者我怎样才能返回一个更容易解析的格式?
任何建议表示赞赏,谢谢!
【问题讨论】: