【发布时间】:2016-02-22 07:59:53
【问题描述】:
我正在使用 SwiftyJSON 在 JSON 中创建数据字典。
现在我想通过friend_health_points 安排一个名为fb_friends 的子词典。
我尝试使用排序或任何其他操作,但出现字符串/JSON 错误。
所以基本上我正在尝试对其进行排序,以便在该数据字典中将 150 个健康点排在第一位,将 20 个排在最后。
这是数据:
var data: JSON = [
"user_id": 7742,
"name": "Bla",
"fb_friends": [
[
"friend_id": 202072,
"friend_name": "Bla Bla",
"friend_photo_url": "https://www.gravatar.com/avatar/",
"friend_health_points": 50,
],
[
"friend_id": 502333,
"friend_name": "hdfghdfghfdgh",
"friend_photo_url": "https://www.gravatar.com/avatar/",
"friend_health_points": 150,
],
[
"friend_id": 202072,
"friend_name": "gjhkghjk",
"friend_photo_url": "https://www.gravatar.com/avatar/",
"friend_health_points": 20,
]
]
【问题讨论】:
-
你的json无效
-
json 工作正常...
标签: arrays json sorting swift2 swifty-json