Use Extended JSON Pointers for array elements
masterThe library supports extended JSON pointers that allow referencing array elements via a unique key instead of a numeric index. This is useful for targeting specific objects within an array.
Syntax: /array/key=value/path (e.g., /a/id=2/data)
Requirements & Warnings:
- You must ensure the field used as a reference key is unique.
- If multiple elements match the key-value pair, the first matching element is selected.
- Key-based referencing can be slow for large arrays; use standard index-based pointers for performance in those cases.
// Example: Accessing data in an array of objects via ID
// JSON: {"a": [{"id": 1, "data": "abc"}, {"id": 2, "data": "def"}]}
// Path: /a/id=2/data
// Result: "def"