Skip to content

can't use forward slash in json path selector #36

Answered by jg-rp
rafalkrupinski asked this question in Q&A
Discussion options

You must be logged in to vote

$.paths['/path'] should work as expected.

.name is the shorthand equivalent to ['name'] or ["name"], and the spec limits the characters allowed in the shorthand name selector. If we want to select a property by name and that name contains reserved/disallowed characters, we must use the longer form quoted name selector.

As to why the RFC authors chose to disallow /, I'm not not sure 🤷‍♂️ .

Here's the relevant part of the grammar for reference.

member-name-shorthand = name-first *name-char
name-first          = ALPHA /
                      "_"   /
                      %x80-D7FF /
                         ; skip surrogate code points
                      %xE000-10FFFF
name-char           …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rafalkrupinski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants