I'm struggling to find an answer to this issue and i keep receiving the error
Cannot invoke "Object.getClass()" because "value" is null
The problem occurs when I have an object - in this case error - that may or may not exist but I need to check for the existence of a sub-field within that object.
"if" : "ctx.error?.containsKey('code')"
This works when the error object exists but the field code does not exist, but fails when the entire error object is absent, with the above error.
I found the answer i needed - i'll post here in case anyone else struggles with a similar problem.
The resolution is to check the existence of the top-level object and then the existence of the field within the object in the same conditional if statement. It seems that the logic short-circuits as soon as the condition is false so doesn't go on to check the existence of the field if the object check fails:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.