UNPKG

@winglet/json

Version:

TypeScript library for safe and efficient JSON data manipulation with RFC 6901 (JSON Pointer) and RFC 6902 (JSON Patch) compliance, featuring prototype pollution protection and immutable operations

16 lines (15 loc) 650 B
/** * Generates a JSON Pointer path from the root object to the target object. * JSON Pointer is a string format according to RFC 6901 specification. * * @template Root - Root object type * @template Target - Target object type * @param root - Root object to start the search from * @param target - Target object to find * @returns JSON Pointer string to the target object or null if not found * * @example * const obj = { a: { b: [1, 2, { c: 'found' }] } }; * getJSONPointer(obj, obj.a.b[2]); // '/a/b/2' */ export declare const getJSONPointer: <Root extends object, Target extends object>(root: Root, target: Target) => string | null;