jsonata-java
jsonata-java copied to clipboard
How to differentiate between null and not existing?
-
When I evaluate the expression
nullFieldagainst the document:{ "nullField": null }I getnull. -
When I evaluate the expressions
nonExistingFieldagainst the same document I still get:null.
When I run the same test in the JSONata Exerciser I get:
- null
- ** no match **
How can I differentiate these two cases in jsonata-java ?
Right now you cannot. This is a design decision in order to avoid having to use a JSON lib like Jackson (see README). Internally, we use an Object to represent null: see:
com.dashjoin.jsonata.Jsonata.NULL_VALUE
com.dashjoin.jsonata.Utils.convertNulls(Object)
We could introduce a mode that sends this to the caller. Did not do that because seemed unintuitive to have to check for null and NULL_VALUE