findJsonNode not working if validationmessage path is "$"
If validation message is at the root, then findJsonNode implementation as per link returning below error :
Exception in thread "main" java.lang.IllegalArgumentException: Invalid input: JSON Pointer expression must start with '/': "$"
at com.fasterxml.jackson.core.JsonPointer.compile(JsonPointer.java:129)
at com.fasterxml.jackson.core.JsonPointer.valueOf(JsonPointer.java:138)
at model.jsoneditor.ValidationContext.findJsonNode(ValidationContext.java:43)
Should we add this special condition check to the first line? Sample -
if("$".equals(msg.getPath())){
return rootNode;
}
There are two specifications for accessing values in a JSON document. Schema Path in networknt closely resembles JSON Pointer spec notation (networknt schema path starts with a "#") and JSON node path resembles JSON Path notation (networknt node path starts with a "$"). Not sure why this was done. But in short you can use "$" to get the root node. @stevehu can give more context here.
When we first start the library, both JSON Path and JSON Pointer were not available. That is why I have used a specific notation for the path. I remember it was inspired by one of the popular Javascript libraries at the time. In hindsight, we should adopt JSON Pointer as it is recommended by the specification team.