mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-05 00:11:08 +00:00
'..'토큰이 있을 때 필터 후 중복 생기는 문제 수정
This commit is contained in:
parent
8ec694090b
commit
d955a1632c
BIN
docs/a8b7ef4627eb555f3abd.module.wasm
Normal file
BIN
docs/a8b7ef4627eb555f3abd.module.wasm
Normal file
Binary file not shown.
Binary file not shown.
BIN
docs/bench/a8b7ef4627eb555f3abd.module.wasm
Normal file
BIN
docs/bench/a8b7ef4627eb555f3abd.module.wasm
Normal file
Binary file not shown.
Binary file not shown.
2
docs/bench/bootstrap.js
vendored
2
docs/bench/bootstrap.js
vendored
@ -192,7 +192,7 @@
|
|||||||
/******/ promises.push(installedWasmModuleData);
|
/******/ promises.push(installedWasmModuleData);
|
||||||
/******/ else {
|
/******/ else {
|
||||||
/******/ var importObject = wasmImportObjects[wasmModuleId]();
|
/******/ var importObject = wasmImportObjects[wasmModuleId]();
|
||||||
/******/ var req = fetch(__webpack_require__.p + "" + {"../browser_pkg/jsonpath_wasm_bg.wasm":"b9cbe12a5983b2270095"}[wasmModuleId] + ".module.wasm");
|
/******/ var req = fetch(__webpack_require__.p + "" + {"../browser_pkg/jsonpath_wasm_bg.wasm":"a8b7ef4627eb555f3abd"}[wasmModuleId] + ".module.wasm");
|
||||||
/******/ var promise;
|
/******/ var promise;
|
||||||
/******/ if(importObject instanceof Promise && typeof WebAssembly.compileStreaming === 'function') {
|
/******/ if(importObject instanceof Promise && typeof WebAssembly.compileStreaming === 'function') {
|
||||||
/******/ promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {
|
/******/ promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {
|
||||||
|
2
docs/bootstrap.js
vendored
2
docs/bootstrap.js
vendored
@ -192,7 +192,7 @@
|
|||||||
/******/ promises.push(installedWasmModuleData);
|
/******/ promises.push(installedWasmModuleData);
|
||||||
/******/ else {
|
/******/ else {
|
||||||
/******/ var importObject = wasmImportObjects[wasmModuleId]();
|
/******/ var importObject = wasmImportObjects[wasmModuleId]();
|
||||||
/******/ var req = fetch(__webpack_require__.p + "" + {"../browser_pkg/jsonpath_wasm_bg.wasm":"b9cbe12a5983b2270095"}[wasmModuleId] + ".module.wasm");
|
/******/ var req = fetch(__webpack_require__.p + "" + {"../browser_pkg/jsonpath_wasm_bg.wasm":"a8b7ef4627eb555f3abd"}[wasmModuleId] + ".module.wasm");
|
||||||
/******/ var promise;
|
/******/ var promise;
|
||||||
/******/ if(importObject instanceof Promise && typeof WebAssembly.compileStreaming === 'function') {
|
/******/ if(importObject instanceof Promise && typeof WebAssembly.compileStreaming === 'function') {
|
||||||
/******/ promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {
|
/******/ promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {
|
||||||
|
@ -79,15 +79,15 @@ impl ValueWrapper {
|
|||||||
|
|
||||||
match self.val.deref() {
|
match self.val.deref() {
|
||||||
RefValue::Array(vec) => {
|
RefValue::Array(vec) => {
|
||||||
let mut ret = Vec::new();
|
let mut set = IndexSet::new();
|
||||||
for v in vec {
|
for v in vec {
|
||||||
if _filter_with_object(v, key, |vv| {
|
if _filter_with_object(v, key, |vv| {
|
||||||
Self::cmp_with_term(vv, et, cmp, false, reverse)
|
Self::cmp_with_term(vv, et, cmp, false, reverse)
|
||||||
}) {
|
}) {
|
||||||
ret.push(v.clone());
|
set.insert(v.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let ret = set.into_iter().collect();
|
||||||
Some(ValueWrapper::new(RefValue::Array(ret).into(), false))
|
Some(ValueWrapper::new(RefValue::Array(ret).into(), false))
|
||||||
}
|
}
|
||||||
_ => None
|
_ => None
|
||||||
@ -109,12 +109,13 @@ impl ValueWrapper {
|
|||||||
_ => {
|
_ => {
|
||||||
match &(*self.val) {
|
match &(*self.val) {
|
||||||
RefValue::Array(vec) => {
|
RefValue::Array(vec) => {
|
||||||
let mut ret = Vec::new();
|
let mut set = IndexSet::new();
|
||||||
for v in vec {
|
for v in vec {
|
||||||
if Self::cmp_with_term(v, et, &cmp, false, reverse) {
|
if Self::cmp_with_term(v, et, &cmp, false, reverse) {
|
||||||
ret.push(v.clone());
|
set.insert(v.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let ret = set.into_iter().collect();
|
||||||
ValueWrapper::new(RefValue::Array(ret).into(), false)
|
ValueWrapper::new(RefValue::Array(ret).into(), false)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -213,6 +213,24 @@ fn op_default() {
|
|||||||
{ "name" : "이름2", "age" : 42, "phone" : "++44 12341234" }
|
{ "name" : "이름2", "age" : 42, "phone" : "++44 12341234" }
|
||||||
]);
|
]);
|
||||||
assert_eq!(friends, jf.into_value());
|
assert_eq!(friends, jf.into_value());
|
||||||
|
|
||||||
|
let ref value = json!({
|
||||||
|
"school": {
|
||||||
|
"friends": [
|
||||||
|
{"name": "친구1", "age": 20},
|
||||||
|
{"name": "친구2", "age": 20}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"friends": [
|
||||||
|
{"name": "친구3", "age": 30},
|
||||||
|
{"name": "친구4"}
|
||||||
|
]});
|
||||||
|
let mut jf = JsonValueFilter::new_from_value(value.into());
|
||||||
|
let mut parser = Parser::new("$..[?(@.age >= 30)]");
|
||||||
|
parser.parse(&mut jf).unwrap();
|
||||||
|
let friends = json!([{ "name" : "친구3", "age" : 30 }]);
|
||||||
|
assert_eq!(friends, jf.into_value());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user