Socket
Socket
Sign inDemoInstall

jsonselect

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jsonselect

Filter out JSON field using Mongoose's select syntax.


Version published
Weekly downloads
21
decreased by-8.7%
Maintainers
1
Install size
923 kB
Created
Weekly downloads
 

Readme

Source

Install

npm install jsonselect;

Usage

select(obj, options)

Options:

  • only: string|array - List of whitespace delimited paths (returned object will only contain those paths)
  • except: string|array - List of whitespace delimited paths (returned object will not contain those paths)

Options can also be a string. See examples.

Paths can be (almost) any JSONPath.

Examples

var select = require('jsonselect');

var a = select(obj, 'username email name.first friends -friends.password');
// equivalent to
var a2 = select(obj, { only: 'username email name.first friends', except: 'friends.password'} );

var b = select(obj, '-password'); // everything except password
// equivalent to
var b2 = select(obj, { except: '-password' });

Using with Mongoose

Coming soon!

TODO

  • better parser for normalized paths
  • properly delete array element using splice/concat

Keywords

FAQs

Last updated on 26 Oct 2012

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc