I can not parse json data due to the fact that the name contains the number 3, not a string Tried it through quicktype.io, but instead of 3 it writes the3, but every time I get nil Tried to create variable 3, but cannot create from number
Here Json
"items": {
"3": {
"name": "Тариф Gold 3 месяцев",
"product_id": 123,
"taxes": {
"total": {
"1": "0.08"
},
"subtotal": {
"1": "0.08"
}
},
"meta_data": []
}
}
Here is my code
// MARK: - ServerStatusElement
struct ServerStatusElement: Decodable {
// var data: DataClass?
var items: Items?
}
// MARK: - DataClass
struct DataClass: Decodable {
var id: Int?
var status: String?
}
struct Items: Codable {
var items: itemsS
}
struct itemsS: Codable {
var the3: Int
}
typealias typeNetwork = [ServerStatusElement]
func fetchSubscribe(url: String) {
let url = URL(string: url)!
URLSession.shared.dataTask(with: url) { (data, response, error) in
guard let data = data else { return }
guard error == nil else { return }
do {
let value = try JSONDecoder().decode(typeNetwork.self, from: data)
print(value[0].items)
} catch let error {
print("Ошибка: \(error)")
}
}.resume()
}