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

Valid identifiers #9

Closed
bettio opened this issue Jul 15, 2020 · 7 comments
Closed

Valid identifiers #9

bettio opened this issue Jul 15, 2020 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@bettio
Copy link

bettio commented Jul 15, 2020

A valid identifier rule (for "dot child" and recursive descent) should be discussed.

  • All implementations agree on [a-zA-Z_][a-zA-Z0-9_]*
  • Most implementations allow a dash in the middle of a identifier (e.g. key-dash)
  • Consensus on $.-key and $.key- has not been investigated
  • Most implementations allow unicode identifiers such as $.屬性
  • Consensus on digits as first identifier character has not been investigated

Proposal

  • Identifier regexp must be simple. e.g. some implementations allow any unicode codepoint except \s, \t, $, ., *, etc... This approach allows writing regexp similar to [^'".*()$?,>=<\-\:\@\[\]\s\t\n\r]*. If this approach is confirmed a list of disallowed codepoints should be identified.
  • - should not be allowed as first identifier character
  • [0-9] as first identifier character should be investigated and discussed.
@glyn
Copy link
Collaborator

glyn commented Jul 15, 2020

I believe the context for this issue is "dot child" (e.g. .somekey) as union/bracket child should allow more esoteric possibilities (e.g. [" "]). Also, it may be relevant to (so called, currently) recursive descent (e.g. ..somekey).

For consensus on digits as first identifier character, dot_notation_with_number and especially dot_notation_with_number_object are relevant.

@remorhaz is currently investigating the use of identifier syntax as part of #5 and may wish to comment.

@bettio
Copy link
Author

bettio commented Jul 16, 2020

See also cburgmer/json-path-comparison#42

@gregsdennis
Copy link
Collaborator

☝️ possible duplication

@cabo cabo added the duplicate This issue or pull request already exists label Mar 3, 2021
@danielaparker
Copy link

danielaparker commented Mar 16, 2021

@bettio

A valid identifier rule (for "dot child" and recursive descent) should be discussed.

  • Most implementations allow a dash in the middle of a identifier (e.g. key-dash)

It depends whether we're looking at the main path or in filter predicates.

In the main path, as in

$.key-dash

there is a consensus to support a dash in identifiers. However, in filter predicates, as in

$[?(@.key-dash == 'value')]

there is no such consensus. Only 13 out of 41 implementations support a dash in identifiers in filter predicates. Most do not.

@goessner
Copy link
Collaborator

I am more in the camp of the non-dash supporters ...

@cabo
Copy link
Member

cabo commented Nov 9, 2021

Closed in #102

@cabo cabo closed this as completed Nov 9, 2021
@gregsdennis
Copy link
Collaborator

What was the resolution? Do we allow hyphens? Was a PR needed to change anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

6 participants