I can not find how to make json readable form. Suppose there is {"x": 5, "b": 6} I would like to get
{ "x":5 }, { "b":6 } The keys are not known in advance
Do so
func convertToDictionary(text: String) -> [String: Any]? { if let data = text.data(using: .utf8) { do { return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] } catch { print(error.localizedDescription) } } return nil } Comes:
["x": 5, "b": 6]