Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dot notation without root in Proposal A #45

Open
glyn opened this issue Jun 8, 2020 · 9 comments
Open

Allow dot notation without root in Proposal A #45

glyn opened this issue Jun 8, 2020 · 9 comments
Labels
Proposal A Anything discussing the advance of the Proposal A for a formal specification of JSONPath

Comments

@glyn
Copy link
Collaborator

glyn commented Jun 8, 2020

Many of the implementations allow eliding the dot where a dot child appears at the start of the path. See https://cburgmer.github.io/json-path-comparison/results/dot_notation_without_root.html.

This seems like reasonable syntactic sugar and I'd like it to be considered for Proposal A. If this proposal is rejected, it would be great to document the rational.

@cburgmer
Copy link
Owner

cburgmer commented Jun 8, 2020

I must admit with Proposal A so far I've been conservative and restrictive. While this might make it easier for implementers, it does not favour the user. So, I'm happy to open up a little.

Dot child without the root so far is the only case I could come up with as a short form. As such I feel introducing a single exception might provide more headache than help. If we see other short forms, that concern would be void though. Do we have others?

@cburgmer cburgmer added the Proposal A Anything discussing the advance of the Proposal A for a formal specification of JSONPath label Jun 8, 2020
@glyn
Copy link
Collaborator Author

glyn commented Jun 8, 2020

Perhaps ..name should be regarded as a contracted form of ...name? I know we probably want to avoid the long form, but the short form could be expressed as a combination of .. and a dot child with elided dot.

@remorhaz
Copy link
Collaborator

remorhaz commented Jun 9, 2020

Here is k8s dialect of JsonPath, and it oficially allows to omit root (k8s uses exponent-io/jsonpath - seems we don't have it in the table yet).

@remorhaz
Copy link
Collaborator

remorhaz commented Jun 9, 2020

As for me, root can be easily omitted in outer expressions ($.foo -> .foo), but that may become confusing in filters ($.foo[?(@.bar==$.baz)] -> .foo[?(@.bar==.baz)]? Or should we omit most commonly used @: .foo[?(.bar==$.baz)]?). Too many defaults may cause more problems than solve.

@glyn
Copy link
Collaborator Author

glyn commented Jun 9, 2020

The OP was about eliding the dot from a dot child at the start of a JSONPath and assumed, perhaps incorrectly, that the root ($) could already be elided at the start of a JSONPath. I think it should certainly be ok to omit both at the start of a JSONPath, but I think it's too confusing and error prone to allow either (or indeed @s) to be omitted within filter expressions.

@cleidiano
Copy link
Collaborator

cleidiano commented Jun 10, 2020

I think that make $ optional could cause more problem then solve, it could make expression more confuse, my personal preference is to maintain $ required.

@glyn
Copy link
Collaborator Author

glyn commented Jun 10, 2020

Here is k8s dialect of JsonPath, and it oficially allows to omit root (k8s uses exponent-io/jsonpath - seems we don't have it in the table yet).

Where is exponent-io/jsonpath used by Kubernetes? I was under the impression that kubectl uses k8s client jsonpath, but I may be wrong.

(I spent half an hour a while back trying to add the k8s client jsonpath to the table, but I lost the will to live trying to suss out the usages of interface {}.)

@remorhaz
Copy link
Collaborator

Where is exponent-io/jsonpath used by Kubernetes?

I've just looked into it's go.mod without further investigations, so I may be wrong, too.

@glyn
Copy link
Collaborator Author

glyn commented Jun 11, 2020

As far as kubectl is concerned,exponent-io/jsonpath seems to be used only during schema validation. A recent PR modifies the JSONPath behaviour of kubectl by changing k8s client jsonpath. Confusing, eh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal A Anything discussing the advance of the Proposal A for a formal specification of JSONPath
Projects
None yet
Development

No branches or pull requests

4 participants