json-path-comparison icon indicating copy to clipboard operation
json-path-comparison copied to clipboard

Add Go package github.com/theory/jsonpath

Open theory opened this issue 4 months ago • 4 comments

I could not figure out how to run the full suite, so started adding tests in theory/jsonpath#22. However, it's not clear to me what the behavior should be when there is no consensus field in a query object. Should it expect a compile error? Selection error? Empty result?

theory avatar Sep 06 '25 22:09 theory

Looks good! Manually merged in 66589d6a9a0ccc799e1f5a0

It should be clear that the consensus does not respect RFC9535, it only reflects the status quo of (often antiquated) implementations. Hopefully there is a huge overlap, eventually fully converging once more and more implementations follow the still newish spec. I believe the reference implementation was to address the full alignment with the RFC, but so far that work has not been completed.

So for me it's less a question about the lack of consensus but rather about the behaviour of queries (syntax) not defined within the RFC. Here the consensus might penalise a lenient implementation if the others are strict (e.g. via compile errors) or vice versa.

cburgmer avatar Oct 06 '25 12:10 cburgmer

Thanks. I get all that, but I still have questions what to do about some situations:

  • Here and here I simply ignore errors when there is no consensus.
  • Here I simply ignore unexpected errors. Should I?

theory avatar Oct 06 '25 18:10 theory

Ah, if the consensus field is missing (e.g. https://github.com/cburgmer/json-path-comparison/blob/master/regression_suite/regression_suite.yaml#L50), then no consensus was reached and only a certain tendency might be derived (https://cburgmer.github.io/json-path-comparison/#array_slice_with_large_number_for_end_and_negative_step). I believe doing nothing is the only option from that perspective.

As for errors, the consensus does track agreement for not supported queries, e.g. https://github.com/cburgmer/json-path-comparison/blob/master/regression_suite/regression_suite.yaml#L50 so I wouldn't skip those in the test, I would check that your implementation doesn't return surprise answers unless intended. Mostly your implementation might actually be returning errors.

cburgmer avatar Oct 06 '25 20:10 cburgmer

Great, that's what I needed to know. I updated my tests to skip cases with no consensus. That eliminates all the unknowns in the tests themselves (I was already tracking errors for those with consensus).

theory avatar Oct 10 '25 14:10 theory