PLPayload LabJS SDK · 1.0.0
Payload Lab / API reference

API reference

Public exports in sdk.js, version 1.0.0. The signatures below are actual callable JavaScript functions.

Input strings are limited to 262,144 UTF-16 code units. Exceptions are standard JavaScript errors.

format(text, indent = 2)

Parse and serialize JSON with indentation.

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

console.log(format('{"enabled":true}'));
Expected value
{
  "enabled": true
}

Exceptions

SyntaxError: malformed JSON

Run examples

pointer(text, path)

Resolve an RFC 6901 JSON Pointer.

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

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

Exceptions

RangeError: missing path; SyntaxError: invalid pointer

Run examples

compare(before, after)

Compare JSON values and return changed paths.

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

console.log(compare('{"a":1}', '{"a":2}'));
Expected value
[
  "/a"
]

Exceptions

SyntaxError: malformed JSON

Run examples