generic-json-swift
generic-json-swift copied to clipboard
Support mutating JSON values
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)
}