Skip to content

json_pointer not functioning as expected from docs #3511

Discussion options

You must be logged in to vote

The JSON pointer "/" refers to the object member with the key "". From the RFC:

For example, given the JSON document

   {
      "foo": ["bar", "baz"],
      "": 0,
      "a/b": 1,
      "c%d": 2,
      "e^f": 3,
      "g|h": 4,
      "i\\j": 5,
      "k\"l": 6,
      " ": 7,
      "m~n": 8
   }

The following JSON strings evaluate to the accompanying values:

    ""           // the whole document
    "/foo"       ["bar", "baz"]
    "/foo/0"     "bar"
    "/"          0
    "/a~1b"      1
    "/c%d"       2
    "/e^f"       3
    "/g|h"       4
    "/i\\j"      5
    "/k\"l"      6
    "/ "         7
    "/m~0n"      8

Edit: The documentation you referenced is in fact wrong.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nlohmann
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