如何结合两个SwiftyJSON对象 [英] How to combine two SwiftyJSON objects
本文介绍了如何结合两个SwiftyJSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个swiftyJSON对象,例如:
I have a swiftyJSON object that looks like for example:
[{
"location" : "http://...",
"img" : "http://...",
"commentCount" : 0,
"timestamp" : 1432460217550,
}]
我希望能够向其附加另一个swiftyJSON对象,使其看起来像:
I want to be able to append another swiftyJSON object to it so that it looks like:
[{
"location" : "http://...",
"img" : "http://...",
"commentCount" : 0,
"timestamp" : 1432460217550,
},
{
"location" : "http://...",
"img" : "http://...",
"commentCount" : 1,
"timestamp" : 1432460217571,
}
]
我不能在swiftyJSON对象上使用 + =
或 .append
.我该怎么办?
I can't use +=
or .append
on swiftyJSON objects. How can I do this?
推荐答案
Victor的答案对我不起作用.但是我通过将JSON对象 data
放入这样的数组来解决了这个问题:
Victor's answer didn't work for me. But I solved the question by putting my JSON object, data
, into an array like this:
var data: [JSON] = []
并使用以下代码:
self.data = self.data + JSON["content"].arrayValue
这篇关于如何结合两个SwiftyJSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文