How to edit json file using Swift?

Can I read the JSON attribute, change it and return to JSON.

Exp: I read the 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 am changing the value of m_array

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

+6
source share

All Articles