Filter out JSON fields using Mongoose's select syntax and JSONPaths.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 0526d82 Oct 26, 2012 @olalonde typo
Permalink
Failed to load latest commit information.
test initial commit Oct 26, 2012
.gitignore initial commit Oct 26, 2012
README.md typo Oct 26, 2012
index.js dont use + prefix anymore Oct 26, 2012
package.json initial commit Oct 26, 2012

README.md

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