jsonata-java icon indicating copy to clipboard operation
jsonata-java copied to clipboard

How to differentiate between null and not existing?

Open ck-c8y opened this issue 1 year ago • 1 comments

  1. When I evaluate the expression nullField against the document: { "nullField": null } I get null.

  2. When I evaluate the expressions nonExistingField against the same document I still get: null.

When I run the same test in the JSONata Exerciser I get:

  1. null
  2. ** no match **

How can I differentiate these two cases in jsonata-java ?

ck-c8y avatar Dec 18 '24 12:12 ck-c8y

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

aeberhart avatar Dec 20 '24 10:12 aeberhart