I have a json which is array of dictionary
response.text = [{
"id": "4635465675",
"name": "Arts",
"pluralName": "Arts",
"shortName": null
}]
json = JSON((response.text)?.data(using: .utf8))
How can i check is value for key "shortName" null or not, say for first dictionary in the array ?
I tried to do like this
if json[0]["shortName"] is NSNull
But it's always true. How can i handle it?
you can directly check as the key of JSON.null
if json[0]["shortName"] == JSON.null {
// show the alert
}
if its your String
if json[0]["shortName"].string == nil {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With