PLPayload LabJS SDK · 1.0.0
Payload Lab / Selecting nested values

Selecting nested values

A pointer begins with a slash, except the empty pointer which denotes the entire document. Escape a tilde as ~0 and a slash in a property name as ~1. Array indices start at zero; a missing member is different from a member whose value is null.

Working example

JavaScript
import { pointer } from "./sdk.js";

console.log(pointer('{"items":[{"id":7}]}', "/items/0/id"));
Expected value
7

When input is invalid

RangeError: missing path; SyntaxError: invalid pointer

Run the example in the local playground before integrating it.
Examples API reference