Open abledbody opened 2 years ago
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.
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.