-
-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Ive stumbled upon a case where my server returned a partially formed body that doesnt include a key.
I see no way in the api to safely access a subscript that may not exist.
Json line 65: json.jsonData = (jsonData as! [String: Any])[s]!
My code:
.onJson { j in
print(j)
if j.stringified?.contains("script") != nil { // added to get around the crash
$script.wrappedValue = j["script"].string
} // added
}Id expect nil as opposed to a crash. I think thats what js would do, just return undefined for a non existing key instead of treating it as an error.
In my xp, though I use force unwraps , I nearly always end up reverting them.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels