You JSON is familiar enough to work with Codable. You have no need to use `[String: Any]`.
import Foundation
let jsonText = """
{ "day" : "2019-01-01", "bob" : 73, "frank" : 34.3}
"""
class MyStruct: Codable {
var day: String
var bob: Int
var frank: Double
}
extension MyStruct: CustomStringConvertible {
var description: String {
return "<day=\(day) bob=\(bob) frank=\(frank)>"
}
}
let jsonData = jsonText.data(using: .utf8)!
do {
let myObject = try JSONDecoder().decode(MyStruct.self, from: jsonData)
print(myObject) //-><day=2019-01-01 bob=73 frank=34.3>
} catch {
print(error)
}
If this is not what you want, you should better try to desribe what is the problem with more examples.