gson-query
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "gson-query", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "json-pointer utilities for querying data", | ||
@@ -10,2 +10,7 @@ "main": "lib/index.js", | ||
}, | ||
"scripts": { | ||
"test": "mocha --recursive 'test/unit/*.test.js' -R spec; exit 0", | ||
"tdd": "watch 'npm run test' lib/ app/ test/; exit 0", | ||
"debug": "devtool node_modules/mocha/bin/_mocha -qc -- --recursive test/unit/*.test.js" | ||
}, | ||
"dependencies": { | ||
@@ -20,6 +25,2 @@ "gson-conform": "^1.0.2", | ||
}, | ||
"scripts": { | ||
"test": "mocha --recursive 'test/unit/*.test.js' -R spec; exit 0", | ||
"tdd": "watch 'npm run test' lib/ app/ test/; exit 0" | ||
}, | ||
"keywords": [], | ||
@@ -26,0 +27,0 @@ "author": "Sascha Goldhofer <noreply@saschagoldhofer.de> (https://github.com/sagold/)", |
@@ -11,8 +11,8 @@ # Json Query | ||
At first, **json-query** acts like a normal [**json-pointer**](https://github.com/sagold/json-pointer) where its match | ||
is passed to the given callback function: | ||
At first, query acts like a normal **json-pointer** where its match is passed to the given callback function: | ||
```js | ||
var query = require("gson-query"); | ||
var data = { | ||
const query = require("gson-query"); | ||
const data = { | ||
"parent": { | ||
@@ -22,4 +22,4 @@ "child": {"id": "child-1"} | ||
}; | ||
query.run(data, "#/parent/child/id", function (value, key, object, jsonPointer) { | ||
// value = "child-1", | ||
query.run(data, "#/parent/child/id", (value, key, object, jsonPointer) => { | ||
// value = "child-1" | ||
// key = "id" | ||
@@ -29,2 +29,5 @@ // object = {"id": "child-1"} | ||
}); | ||
// or get the result in an array | ||
var match = query.get(data, "#/parent/child/id"); | ||
// [ ["child-1", "id", {"id":"child-1"}, "#/parent/child/id"] ] | ||
``` | ||
@@ -36,4 +39,4 @@ | ||
```js | ||
var query = require("gson-query"); | ||
var data = { | ||
const query = require("gson-query"); | ||
const data = { | ||
"parent": { | ||
@@ -49,2 +52,5 @@ "child": {"id": "child-1"} | ||
}); | ||
// or get the result in an array | ||
var match = query.get(data, "#/parent/child/id"); | ||
// [ ["child-1", ...], ["child-2", ...] ] | ||
``` | ||
@@ -51,0 +57,0 @@ |
12837
157