You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
Say you have a JSON that looks like this: { "someThing": { "fieldA": 10.0, "fieldC": 5.0 } }
And some code that looks like this: var fieldB = json["someThing"]["fieldB"]
There's no way to check if you successfully found an entry in that spot. If you try and access the value, float fieldBValue = fieldB it will simply fail an assertion.
I recommend changing most of the assertions in Json class to exceptions, so that they can be caught and handled by the user of the API.
The text was updated successfully, but these errors were encountered:
abledbody
changed the title
No way to check if the entry in the JSON actually exists.
No way to check if an entry in the JSON actually exists.
May 2, 2022
Also, adding a new entry in the internal dictionary every time you can't find a key is an extremely bad idea, because it allocates more memory for an action that shouldn't even (noticeably) mutate the class. This should also be an exception.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Say you have a JSON that looks like this:
{ "someThing": { "fieldA": 10.0, "fieldC": 5.0 } }
And some code that looks like this:
var fieldB = json["someThing"]["fieldB"]
There's no way to check if you successfully found an entry in that spot. If you try and access the value,
float fieldBValue = fieldB
it will simply fail an assertion.I recommend changing most of the assertions in Json class to exceptions, so that they can be caught and handled by the user of the API.
The text was updated successfully, but these errors were encountered: