Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@swagger-api/apidom-json-pointer
Advanced tools
Evaluate JSON Pointer expressions against ApiDOM.
@swagger-api/apidom-json-pointer is an npm package that provides utilities for working with JSON Pointers, which are a way to reference specific parts of a JSON document. This package is particularly useful for navigating and manipulating JSON data structures in a standardized way.
Creating JSON Pointers
This feature allows you to create a JSON Pointer instance from a string. The created pointer can then be used to reference specific parts of a JSON document.
const { JsonPointer } = require('@swagger-api/apidom-json-pointer');
const pointer = JsonPointer.create('/path/to/element');
console.log(pointer.toString()); // Outputs: /path/to/element
Resolving JSON Pointers
This feature allows you to resolve a JSON Pointer against a JSON document to retrieve the value at the specified location.
const { JsonPointer } = require('@swagger-api/apidom-json-pointer');
const document = { path: { to: { element: 'value' } } };
const pointer = JsonPointer.create('/path/to/element');
const value = pointer.resolve(document);
console.log(value); // Outputs: 'value'
Setting Values with JSON Pointers
This feature allows you to set a value at a specific location in a JSON document using a JSON Pointer.
const { JsonPointer } = require('@swagger-api/apidom-json-pointer');
const document = { path: { to: { element: 'value' } } };
const pointer = JsonPointer.create('/path/to/element');
pointer.set(document, 'newValue');
console.log(document.path.to.element); // Outputs: 'newValue'
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.
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
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';
1.0.0-beta.2 (2024-11-22)
FAQs
Evaluate JSON Pointer expressions against ApiDOM.
The npm package @swagger-api/apidom-json-pointer receives a total of 422,441 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.