How to append new data to an existing JSON array(swiftyJSON)

后端 未结 6 1041
梦谈多话
梦谈多话 2021-01-08 00:55

I have an array of SwiftyJson data that I have declared and filled it with data .The code I\'m using to fill the hoge array is this : self.hoge = JSON(data: data!)

6条回答
  •  死守一世寂寞
    2021-01-08 01:01

    You can use the merge function for this. https://github.com/SwiftyJSON/SwiftyJSON#merging

    var array: JSON = [1, 2, 3]
    array = try! array.merged(with: [4])
    // -> [1, 2, 3, 4]
    

提交回复
热议问题