kPointer¶
kPointer is a family of Kotlin Multiplatform libraries for RFC 6901 JSON Pointer support. It provides parsing, navigation, and manipulation of JSON Pointer (and related) expressions, a generic adapter API for integrating any object-tree representation, and ready-made implementations for kotlinx.serialization JSON, YamlKt YAML, and KSoup HTML/XML.
A JSON Pointer is a compact string that addresses a single value inside a tree — /user/name,
/items/0/price, /a~1b — much like a filesystem path addresses a file. kPointer lets you parse
those strings, walk them across a document, and produce new documents by setting or removing the
value at a path.
Supports JVM, Android, iOS, Linux, JavaScript, and WebAssembly targets (see each module for its exact target list).
Migrating from cw-json?
kPointer supersedes the cw-json library. The API
surface is mostly the same; the class rename (JsonPointer → KPointer) and the other
edits you need are documented in the project
README.
Modules¶
| Module | What it does | API Docs | Source |
|---|---|---|---|
kpointer-core |
RFC 6901 pointer parsing, segment access, and pointer arithmetic. No document model. | API | Codeberg |
kpointer-adapter |
A generic adapter API (KpaStruct, KpaList, KpaPrimitive) plus pointer-based get / mutate, decoupled from any concrete tree representation. |
API | Codeberg |
kpointer-kxs |
Adapters and convenience extensions for kotlinx.serialization JsonObject / JsonArray. |
API | Codeberg |
kpointer-yamlkt |
Adapters and convenience extensions for YamlKt YamlMap / YamlList. |
API | Codeberg |
kpointer-ksoup |
Read-only adapters exposing KSoup HTML/XML documents as pointer-addressable trees. | API | Codeberg |
If you only need to parse and manipulate pointer strings, depend on kpointer-core alone. If you
want to read or mutate a document, pick the adapter module that matches your representation — each
one pulls in kpointer-adapter and kpointer-core transitively.
Where to next¶
- Creating pointers — build and manipulate
KPointervalues from RFC 6901, fragment, and dot-notation strings. - The document model — understand
KpaStruct,KpaList, andKpaPrimitive: how kPointer represents document nodes across all adapter families. - Working with JSON — read and mutate kotlinx.serialization documents by pointer.
- Working with YAML — the same, for YamlKt.
- Working with XML & HTML — address KSoup trees by pointer.
- Custom adapters — teach kPointer about your own tree type.
- Porting to another language — the language-agnostic conformance suite and how to build a workalike.
The full generated API documentation is in the API Reference.
License¶
kPointer is licensed under the Apache License, Version 2.0.