string syntax for identifying a specific value


JSON Pointer is a standard pointer syntax used to access specific values within a JSON document, as defined in RFC 6901.

URI can be used to point to specific elements within complex nested JSON data.

Stands for “Uniform Resource Identifier,” composed of a scheme, host, and path. JSON Pointer corresponds to the path in a URI.


Uses of JSON Pointer

JSON Pointer navigates object properties and array indexes to access specified values.

You write the path to retrieve or assign (overwrite) values.

JSON requires a key name (token) to store values. See the sample pointers below.

"/test/json/object/array"

The above sample has four segments (/), and specifies object properties or array indexes with tokens separated by segments.


Basic Usage

Assume that the JSON loaded into memory has the following content.

{
    "sample":{
        "object"{
            "array":[1,2,3,4],
            "name": "aster",
            "year": 2024
        }
    }
}
Root Specification
Details

e.g.

"/"

At least one segment is required, so start with "/".

Specify the “sample” object directly under the root.
Details

e.g.

"/sample"

The notation "/sample" specifies the object called "sample" directly under the root.

Omitting the root segment in the database will result in a syntax error. Here is an example of a syntax error.

Error::RootSegment
"sample/object"
Retrieve data from the index of an array element.
Details

You can retrieve values by writing the index value of the array element in the pointer.

"/sample/object/array/3"

In the sample, 3 is specified, so the result is array[3] == 4.

{
    "array":[1,2,3,4]
}

The array index is 0 Based Index.

  • array[0] = 1
  • array[1] = 2
  • array[2] = 3

So in the sample you get the value 4.

The syntax of JSON Pointer is very simple.

Please utilize JSON Pointer as a powerful tool to easily manipulate JSON data.