update example

This commit is contained in:
freestrings
2019-06-23 23:59:18 +09:00
parent 967df1b787
commit 59dad2ea02
9 changed files with 159 additions and 60 deletions

View File

@ -18,14 +18,20 @@ let ret = [
{"name": "친구1", "age": 20}
];
let selector = new jsonpath.Selector();
selector.path('$..friends[0]');
selector.value(jsonObj);
const path = '$..friends[0]';
let selectToObj = selector.selectTo();
let selectToString = selector.selectToStr();
let ret1 = jsonpath.select(jsonObj, path);
let ret2 = jsonpath.compile(path)(jsonObj);
let ret3 = jsonpath.selector(jsonObj)(path);
let selector = new jsonpath.Selector();
selector.path(path);
selector.value(jsonObj);
let ret4 = selector.select();
console.log(
JSON.stringify(ret) == JSON.stringify(selectToObj),
JSON.stringify(ret) == selectToString
);
JSON.stringify(ret) == JSON.stringify(ret1),
JSON.stringify(ret) == JSON.stringify(ret2),
JSON.stringify(ret) == JSON.stringify(ret3),
JSON.stringify(ret) == JSON.stringify(ret4)
);

12
examples/nodejs-wasm/package-lock.json generated Normal file
View File

@ -0,0 +1,12 @@
{
"name": "jsonpath-wasm-nodejs-example",
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"jsonpath-wasm": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/jsonpath-wasm/-/jsonpath-wasm-0.2.2.tgz",
"integrity": "sha512-ftbf9nRLfHPf6RPBGCGvy27Cfh8DNU0Y446cT7znGf2UjbvFBE0Jwp2cwRGPvLBwIcD93BSp2o2BPq8cN7WLQw=="
}
}
}

View File

@ -4,6 +4,6 @@
"start": "node index.js"
},
"dependencies": {
"jsonpath-wasm": "0"
"jsonpath-wasm": "^0.2.2"
}
}
}