I have a swiftyJSON object that looks like for example:
[{
"location" : "http://...",
"img" : "http://...",
"commentCount" : 0,
"timestamp" : 1432460217550,
}]
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,
}
]
I can't use +=
or .append
on swiftyJSON objects. How can I do this?
JSONObject to merge two JSON objects in Java. We can merge two JSON objects using the putAll() method (inherited from interface java.
This is a simple tool for merging multiple data. json files into one.
As you said, swiftyJSON does not have an append functionality.
What you can do is parse the swiftyJSON objects into an array of type anyObject and append them.
let json = JSON(data: data!)
var JSONObject = JSON(json["content"].arrayObject! + json["content"].arrayObject!)
Data -> NSData Object received from a HTTP request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With