• Finds a target in document specified by JSON Pointer. Also returns the object containing the target and key used to reference that object.

    Throws Error('NOT_FOUND') if pointer does not result into a value in the middle of the path. If the last element of the path does not result into a value, the lookup succeeds with val set to undefined. It can be used to discriminate missing values, because undefined is not a valid JSON value.

    If last element in array is targeted using "-", e.g. "/arr/-", use isArrayEnd to verify that:

    const ref = find({arr: [1, 2, 3], ['arr', '-']});
    if (isArrayReference(ref)) {
    if (isArrayEnd(ref)) {
    // ...
    }
    }

    Parameters

    • val: unknown
    • path: Path

    Returns Reference