🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@mischnic/json-sourcemap

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mischnic/json-sourcemap

Generate positions for values in JSON and JSON5 strings

0.1.1
latest
Source
npm
Version published
Weekly downloads
472K
-32.58%
Maintainers
1
Weekly downloads
 
Created

What is @mischnic/json-sourcemap?

@mischnic/json-sourcemap is an npm package that provides functionality to generate and work with source maps for JSON files. This can be particularly useful for debugging and understanding changes in JSON data structures by mapping positions in the JSON text to the corresponding data structures.

What are @mischnic/json-sourcemap's main functionalities?

Generating Source Maps

This feature allows you to generate a JSON string along with a source map that maps positions in the JSON text to the corresponding data structures.

const { stringify } = require('@mischnic/json-sourcemap');

const obj = { foo: 'bar', baz: [1, 2, 3] };
const { json, pointers } = stringify(obj);

console.log(json); // JSON string
console.log(pointers); // Source map

Parsing JSON with Source Maps

This feature allows you to parse a JSON string and generate a source map that maps positions in the JSON text to the corresponding data structures.

const { parse } = require('@mischnic/json-sourcemap');

const json = '{"foo":"bar","baz":[1,2,3]}';
const { data, pointers } = parse(json);

console.log(data); // Parsed JSON object
console.log(pointers); // Source map

Querying Source Maps

This feature allows you to query the source map to find the position of specific elements in the JSON text.

const { parse } = require('@mischnic/json-sourcemap');

const json = '{"foo":"bar","baz":[1,2,3]}';
const { data, pointers } = parse(json);

const pointer = pointers['/baz/1'];
console.log(pointer); // { value: 2, valueEnd: 16, key: '1', keyEnd: 15, parent: '/baz' }

Other packages similar to @mischnic/json-sourcemap

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

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.

Install

Related posts