mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-06-22 20:31:37 +00:00
update example
This commit is contained in:
@ -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
12
examples/nodejs-wasm/package-lock.json
generated
Normal 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=="
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,6 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsonpath-wasm": "0"
|
||||
"jsonpath-wasm": "^0.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user