Hi,
again, thanks for maintaining this library! ;)
I am dealing with the following case:
node.exists(jsonPath)
where jsonPath is given as input by the user.
The path must match something in the tree.
If not, it is a user error.
However, for users it might be difficult to debug what they are doing wrong when writing the paths.
They just get a false on the exists() calls.
To help my users, I need to give them some hints on what they are doing wrong.
My idea was to tell them what is the "closest" match for their queries.
For example, consider the following path on an OpenAPI schema:
jsonPath = $.paths["/api"].post.parameters[?(@.name=="x")]
the user gets node.exists(jsonPath) == false, as they made a mistake, because there is no post and rather they meant a get.
Would be good to have something like:
node.closestMatch(jsonPath) == $.paths["/api"]
so they can understand that their problem starts with the .post part.
To achieve this, the jsonPath needs to be split in tokens, and then apply exists() on shorter and shorter paths until true is returned.
Do you think you could add such feature?
Or is there already something in the library that could be used to achieve this?
many thanks!
Hi,
again, thanks for maintaining this library! ;)
I am dealing with the following case:
node.exists(jsonPath)where
jsonPathis given as input by the user.The path must match something in the tree.
If not, it is a user error.
However, for users it might be difficult to debug what they are doing wrong when writing the paths.
They just get a
falseon theexists()calls.To help my users, I need to give them some hints on what they are doing wrong.
My idea was to tell them what is the "closest" match for their queries.
For example, consider the following path on an OpenAPI schema:
jsonPath = $.paths["/api"].post.parameters[?(@.name=="x")]the user gets
node.exists(jsonPath) == false, as they made a mistake, because there is nopostand rather they meant aget.Would be good to have something like:
node.closestMatch(jsonPath) == $.paths["/api"]so they can understand that their problem starts with the
.postpart.To achieve this, the
jsonPathneeds to be split in tokens, and then applyexists()on shorter and shorter paths untiltrueis returned.Do you think you could add such feature?
Or is there already something in the library that could be used to achieve this?
many thanks!