Nowhere I can not find how to make a json readable type. Suppose there { "x": 5, "b": 6} I would like to get as
{
"x":5
},
{
"b":6
}
Keys are not known
I am doing 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]