Closed danousna closed 4 years ago
Is using Codable
an option? If so you could mark object
as optional:
struct MyData : Codable {
let object: Object?
let some: String
struct Object : Codable {
let name: String
// ...
}
}
Then Request
can handle decoding it for you
Indeed it works.
Thanks for the help !
Hi there,
Thanks for the library.
I am using an api which returns the following json :
The
object
key can sometimes be empty.However, I want to access the
name
key using my Json object. But when theobject
is empty, my app crashes because of course, it cannot get to thename
key (Could not cast value of type 'NSNull' (0x...........) to 'NSDictionary'
).I can't figure out how to test for this.
Thanks for the help.