generic-json-swift icon indicating copy to clipboard operation
generic-json-swift copied to clipboard

Support mutating JSON values

Open berikv opened this issue 2 years ago • 0 comments

Allow mutation of JSON object and its members:

func updateCost(data: Data) -> Data {
   var json = try JSONDecoder().decode(JSON.self, from: data)
   json["items"].arrayValue![3]["cost"] = 53
   return try JSONEncoder().encode(json)
}

berikv avatar Aug 08 '22 11:08 berikv