1. jsonpointer
Simple JSON Addressing.
jsonpointer
Package: jsonpointer
Created by: janl
Last modified: Wed, 13 Jul 2022 12:46:10 GMT
Version: 5.0.1
License: MIT
Downloads: 24,041,279
Repository: https://github.com/janl/node-jsonpointer

Install

npm install jsonpointer
yarn add jsonpointer

JSON Pointer for Node.js

This is an implementation of JSON Pointer.

CLI

Looking to filter JSON from the command line? Check out jsonpointer-cli.

Usage

 var jsonpointer = require('jsonpointer');
var obj = { foo: 1, bar: { baz: 2}, qux: [3, 4, 5]};

jsonpointer.get(obj, '/foo');     // returns 1
jsonpointer.get(obj, '/bar/baz'); // returns 2
jsonpointer.get(obj, '/qux/0');   // returns 3
jsonpointer.get(obj, '/qux/1');   // returns 4
jsonpointer.get(obj, '/qux/2');   // returns 5
jsonpointer.get(obj, '/quo');     // returns undefined

jsonpointer.set(obj, '/foo', 6);  // sets obj.foo = 6;
jsonpointer.set(obj, '/qux/-', 6) // sets obj.qux = [3, 4, 5, 6]

var pointer = jsonpointer.compile('/foo')
pointer.get(obj)    // returns 1
pointer.set(obj, 1) // sets obj.foo = 1

Testing

$ npm test
All tests pass.
$

Node.js CI

Author

(c) 2011-2021 Jan Lehnardt [email protected] & Marc Bachmann https://github.com/marcbachmann

Thanks to all contributors.

License

MIT License.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code