JsonPointer

RFC 6901 JSON Pointer — parse and data walk.

The one pointer implementation the library shares: $get reads through it, and so does every mutation path. Keeping it in one place is what makes "a pointer means the same thing everywhere" a fact rather than a convention.

Functions

Link copied to clipboard
fun index(segment: String): Int?

The array index segment denotes, or null when it is not a canonical index token. Leading zeroes and - are deliberately not indices — /- is the append position, which writers handle separately.

Link copied to clipboard
fun parse(pointer: String): List<String>?

Parses a pointer into unescaped segments, or null when malformed (callers raise their own typed identity — a template bug, not absent data). A pointer must start with / and have at least one segment; escapes: ~1/, ~0~, anything else after ~ is malformed.

Link copied to clipboard
fun walk(root: <Error class: unknown class>, segments: List<String>): <Error class: unknown class>

Walks segments down from root. Any miss — absent key, non-index or out-of-bounds array step, stepping into a scalar — degrades to JsonNull.