【发布时间】:2016-08-12 08:38:05
【问题描述】:
要转换的字符串:
[{"description": "Hi","id":2,"img":"hi.png"},{"description": "pet","id":10,"img":"pet.png"},{"description": "Hello! :D","id":12,"img":"hello.png"}]
转换字符串的代码:
var json = JSON(stringLiteral: stringJSON)
字符串被转换为 JSON,当我尝试计算这个 JSON 中有多少块(预期答案 = 3)时,我得到 0。
print(json.count)
控制台输出:0
我错过了什么?非常感谢您的帮助。
【问题讨论】:
-
如果我没记错的话是:json.array.count
-
当我打印“json”时,它会显示所有数据,但是当我打印“json.count”时,它会显示 0 而不是 3:C
标签: ios json swift swifty-json