Skip to content

Relative JSON Pointer specification inconsistency #1175

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

Open
omgmashina opened this issue Jan 21, 2022 · 4 comments
Open

Relative JSON Pointer specification inconsistency #1175

omgmashina opened this issue Jan 21, 2022 · 4 comments

Comments

@omgmashina
Copy link

omgmashina commented Jan 21, 2022

First issue: text part of section 3. Syntax does not describe [index-manipulation] which is present in ABNF.

A Relative JSON Pointer is a Unicode string in UTF-8 encoding (see
RFC 8259, Section 8 [RFC8259]), comprising a non-negative integer,
followed by either a '#' (%x23) character or a JSON Pointer (RFC 6901
[RFC6901]).

relative-json-pointer =  non-negative-integer [index-manipulation] <json-pointer>
relative-json-pointer =/ non-negative-integer "#"
index-manipulation    =  ("+" / "-") non-negative-integer
non-negative-integer      =  %x30 / %x31-39 *( %x30-39 )
        ; "0", or digits without a leading "0"

Second issue: one of examples (0-1#) does not comply with ABNF -- # can't be used together with [index-manipulation].

                   For example, given the JSON document:

                         {
                            "foo": ["bar", "baz"],
                            "highly": {
                               "nested": {
                                  "objects": true
                               }
                            }
                         }

     Starting from the value "baz" (inside "foo"), the following JSON
               strings evaluate to the accompanying values:

                     "0"                         "baz"
                     "1/0"                       "bar"
                     "0-1"                       "bar"
                     "2/highly/nested/objects"   true
                     "0#"                        1
                     "0-1#"                      0
                     "1#"                        "foo"

Is ABNF the ultimate truth? Should I refer to it when implementing Relative JSON Pointers? Or does ABNF require fixes? In any case, I could make a pull request with fixes, if anyone can tell me what exactly needs to be fixed.

@handrews
Copy link
Contributor

handrews commented May 20, 2022

I can see this going either way. I believe the spec requires that the instance location to which # is applied must actually exist, which means that you can't just get the non-manipulated index and then add an adjustment to it. Or, rather, you would have to add the adjustment and then see if the resulting location exists, which is somewhat annoying. So I lean towards supporting 0-1#

@Relequestual I think this should be fixed in the patch release? If you agree with me here it's just that something was left out of the ABNF, so this would not be adding to the set of functionality expressed by the examples. Granted, the ABNF should be normative, but I think the intent was to support this.

@handrews
Copy link
Contributor

handrews commented May 27, 2022

Per Slack conversation with @Relequestual I believe that there will not be a release of the Relative JSON Pointer spec alongside the immanent JSON Schema patch release, but I am advocating for (and volunteering to do the work for) an update of Relative JSON Pointer shortly afterwards.

@notEthan
Copy link
Contributor

It looks like this has been resolved by #1400 and can be closed.

@gregsdennis
Copy link
Member

Kind of. The spec still hasn't been republished. Henry tells me there's a bit more he wants to clarify/adjust on it, but he hasn't had time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Discussion
Development

Successfully merging a pull request may close this issue.

4 participants