V
V
Vegetable2020-05-24 17:05:24
JSON
Vegetable, 2020-05-24 17:05:24

In a JSON file, one of the keys "*" how to parse into the model?

Can you please tell me if it is possible to parse such json into the model?
The problem is that it is impossible to name a property in the * model and I don’t understand what to do with the model, because the property must be named the same as the key.
How to put a pair of "*": "Affenpinscher" into the model?
Or am I focusing on the model in vain?
5eca7c911fbe4001951846.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Grib, 2020-05-24
@Vegetable

Create a Codable model according to your JSON here https://app.quicktype.ioand already on the finished model

Alamofire.request("", method: .get, parameters: parameters).validate().responseJSON { response in
            let jsonDecoder = JSONDecoder()
            switch(response.result) {
            case .success:
                if let data = response.data {
                do {
                    let json = try jsonDecoder.decode(Model.self, from: data)
                    completion(json, nil)
                } catch let error {
                    print("\n Json Error \n", error.localizedDescription)
                }
....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question