How to check if a key exists without silently generating null objects on the path #2041
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
I have a deep nested JSON data model with a lot of optional keys and optional sub- structures.
When trying to read a non-existing optional key in a not yet existing path the library silently creates this path. When parts of the branch are not existing 'null' keys / 'null' structures are silently generated into the JSON model.
Even checking for a key generates the elements on its path:
This generates following JSON output:
I tried also the 'find' method with the same result. Addressing a non-existing key generates it.
To check each sub-level with 'contain' or 'find' before accessing the next sub-key is not a real option
because the nesting depth is 10 and the model contains a few thousand 1000 optional keys.
Is there any hint how to check if a key exists without checking each key on its path?
Any help is welcome
Christian
The text was updated successfully, but these errors were encountered: