
Company News
Socket Joins the OpenJS Foundation
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.
@swagger-api/apidom-json-pointer
Advanced tools
apidom-json-pointer is a package that evaluates JSON Pointer against ApiDOM.
You can install this package via npm CLI by running the following command:
$ npm install @swagger-api/apidom-json-pointer
This is the recommended API for use in new projects. It is fully compliant with RFC 6901 and supports all aspects of JSON Pointer. Uses @swaggerexpert/json-pointer under the hood and fully reflects its API.
Evaluation is contextual to ApiDOM realm - meaning evaluate function
expects only ApiDOM as the first argument.
import { evaluate } from '@swagger-api/apidom-json-pointer/modern';
This is a legacy API not recommended for use in new projects. It is provided for backward compatibility only. The legacy API implementation is not RFC 6901 compliant, nor does it support all features of JSON Pointer.
Importing legacy API from @swagger-api/apidom-json-pointer is equivalent to importing from @swagger-api/apidom-json-pointer/legacy.
import { evaluate } from '@swagger-api/apidom-json-pointer';
or
import { evaluate } from '@swagger-api/apidom-json-pointer/legacy';
import { ObjectElement } from '@swagger-api/apidom-core';
import { evaluate } from '@swagger-api/apidom-json-pointer';
const apidom = new ObjectElement({ a: { b: 'c' } });
const result = evaluate('/a/b', apidom);
// => StringElement('c')
Parses JSON Pointer into list of tokens.
import { parse } from '@swagger-api/apidom-json-pointer';
const tokens = parse('/a/b'); // => ['a', 'b']
Compiles list of tokens into JSON Pointer.
import { compile } from '@swagger-api/apidom-json-pointer';
const jsonPointer = compile(['a', 'b']); // => '/a/b'
Escapes/unescapes tokens of JSON Pointer.
import { escape, unescape } from '@swagger-api/apidom-json-pointer';
escape('~a/'); // => '~0a~1'
unescape('~0a~1'); // => '~a/'
Handles case of URI Fragment Identifier Representation.
import { uriToPointer } from '@swagger-api/apidom-json-pointer';
uriToPointer('https://example.com/path/#/a/b'); // => '/a/b'
If invalid JSON Pointer is supplied to parse or evaluate functions, InvalidJsonPointerError
is thrown.
import { InvalidJsonPointerError } from '@swagger-api/apidom-json-pointer';
If valid JSON Pointer is supplied to evaluate function and the pointer cannot be evaluated against
ApiDOM fragment, EvaluationJsonPointerError is thrown.
import { EvaluationJsonPointerError } from '@swagger-api/apidom-json-pointer';
The 'jsonpointer' package provides similar functionality for working with JSON Pointers. It allows you to get and set values in JSON documents using JSON Pointers. Compared to @swagger-api/apidom-json-pointer, 'jsonpointer' is more widely used and has a simpler API.
The 'json-ptr' package is another alternative for working with JSON Pointers. It offers a comprehensive set of features for creating, resolving, and manipulating JSON Pointers. It also includes additional utilities for working with JSON References. 'json-ptr' is more feature-rich compared to @swagger-api/apidom-json-pointer.
FAQs
Evaluate JSON Pointer expressions against ApiDOM.
The npm package @swagger-api/apidom-json-pointer receives a total of 694,224 weekly downloads. As such, @swagger-api/apidom-json-pointer popularity was classified as popular.
We found that @swagger-api/apidom-json-pointer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.