Subject: [art] Question regarding RFC 6901

From: Darren Doyle <[email-masked]>
Date: Wed, 16 Nov 2016 06:29:40 +0000

I just wanted to submit something for consideration regarding the JSON Pointer specification (RFC 6901).

Currently the specification makes no consideration for JavaScript objects which contain numerical property keys—in all of the path examples of such.

Consider the following path: "/foo/1"

It is unclear whether this should point to this target: { "foo": [null, "target"] }
or to this target: { "foo": { "1": "target" } }

Both are acceptable JSON. I'm finding that parsing engines generally are able to find an existing path, but adding data to a non-existent path is where things start to break down.

PROPOSED SOLUTION:

Use the slash / to always indicate an object reference, and the colon : to always indicate an array reference. With this in mind:

  *   "/foo/1" evaluates to  { "foo": { "1": "target" } }
  *   "/foo:1" evaluates to { "foo": [ null, "target" ] }

If a colon is needed, it can simply be escaped as the other special characters with ~2 such that

  *   "/foo/1~2bar" evaluates to  { "foo": { "1:bar": "target" } }

Thank you for your consideration!
Darren Doyle