How to edit file json with Swift?
Asked Answered
O

0

9

Can I read a attribute from JSON, change, and push back to the JSON.

Exp: I read json file

let jsonData:NSData = LocalFile.ReadFile(fileName)

let json = try NSJSONSerialization.JSONObjectWithData(jsonData, options: .AllowFragments)

if let m_array = json as? [[String: AnyObject]]{...}

  • I change value of m_array

  • I want to save the json file with a part new content of m_array ? How can do that?

Oleate answered 17/8, 2016 at 14:29 Comment(1)
I think you can try swiftyJSON. It has a method to convert NSData to JSON object and has a method to get rawString back from JSON object. #31142591, github.com/SwiftyJSON/SwiftyJSON#raw-objectTavy

© 2022 - 2024 — McMap. All rights reserved.