mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-26 18:02:14 +00:00
publish 0.2.3 - fixed #7
This commit is contained in:
commit
f1fda2af13
@ -1,9 +1,9 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jsonpath_lib"
|
name = "jsonpath_lib"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
authors = ["Changseok Han <freestrings@gmail.com>"]
|
authors = ["Changseok Han <freestrings@gmail.com>"]
|
||||||
|
|
||||||
description = "It is JsonPath engine written in Rust. it provide a similar API interface in Webassembly and Javascript also. - Webassembly Demo: https://freestrings.github.io/jsonpath"
|
description = "It is JsonPath engine written in Rust. it provide a similar API interface in Webassembly and Javascript too. - Webassembly Demo: https://freestrings.github.io/jsonpath"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
keywords = ["jsonpath", "json", "webassembly", "nodejs", "javascript"]
|
keywords = ["jsonpath", "json", "webassembly", "nodejs", "javascript"]
|
||||||
@ -19,11 +19,10 @@ travis-ci = { repository = "freestrings/jsonpath", branch = "master" }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.6.0"
|
env_logger = "0.6"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||||
indexmap = "1.0.2"
|
array_tool = "1.0.3"
|
||||||
array_tool = "~1.0.3"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bencher = "0.1.5"
|
bencher = "0.1.5"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
`Rust` 버전 [JsonPath](https://goessner.net/articles/JsonPath/) 구현이다. `Webassembly`와 `Javascript`에서도 유사한 API 인터페이스를 제공 한다.
|
`Rust` 버전 [JsonPath](https://goessner.net/articles/JsonPath/) 구현이다. `Webassembly`와 `Javascript`에서도 유사한 API 인터페이스를 제공 한다.
|
||||||
|
|
||||||
It is JsonPath [JsonPath](https://goessner.net/articles/JsonPath/) engine written in `Rust`. it provide a similar API interface in `Webassembly` and` Javascript` also.
|
It is JsonPath [JsonPath](https://goessner.net/articles/JsonPath/) engine written in `Rust`. it provide a similar API interface in `Webassembly` and` Javascript` too.
|
||||||
|
|
||||||
- [Webassembly Demo](https://freestrings.github.io/jsonpath/)
|
- [Webassembly Demo](https://freestrings.github.io/jsonpath/)
|
||||||
- [NPM jsonpath-wasm - webassembly](https://www.npmjs.com/package/jsonpath-wasm)
|
- [NPM jsonpath-wasm - webassembly](https://www.npmjs.com/package/jsonpath-wasm)
|
||||||
|
@ -14,7 +14,7 @@ exclude = ["artifacts.json", "index.node"]
|
|||||||
neon-build = "0.2.0"
|
neon-build = "0.2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
jsonpath_lib = "0.2.2"
|
jsonpath_lib = "0.2.3"
|
||||||
#jsonpath_lib = { path = "../../" }
|
#jsonpath_lib = { path = "../../" }
|
||||||
neon = "0.2.0"
|
neon = "0.2.0"
|
||||||
serde_json = { version = "1.0", features = ["preserve_order"] }
|
serde_json = { version = "1.0", features = ["preserve_order"] }
|
||||||
|
@ -894,35 +894,35 @@ describe('ISSUE test', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('Invalid wildcard filter results #7', (done) => {
|
it('Invalid wildcard filter results #7', (done) => {
|
||||||
//
|
|
||||||
// function select(json, expected, paths) {
|
function select(json, expected, paths) {
|
||||||
// for (var i = 0 ; i < paths.length ; i++) {
|
for (var i = 0 ; i < paths.length ; i++) {
|
||||||
// let result = jsonpath.select(json, paths[i]);
|
let result = jsonpath.select(json, paths[i]);
|
||||||
// if (JSON.stringify(result) !== JSON.stringify(expected)) {
|
if (JSON.stringify(result) !== JSON.stringify(expected)) {
|
||||||
// throw Error("Error: " + paths[i]);
|
throw Error("Error: " + paths[i]);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// select(
|
select(
|
||||||
// ["string", 42, { "key": "value" }, [0, 1]],
|
["string", 42, { "key": "value" }, [0, 1]],
|
||||||
// ["string", 42, { "key": "value" }, [0, 1]],
|
["string", 42, { "key": "value" }, [0, 1]],
|
||||||
// ["$.*", "$[*]"]
|
["$.*", "$[*]"]
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// select(
|
select(
|
||||||
// ["string", 42, { "key": "value" }, [0, 1]],
|
["string", 42, { "key": "value" }, [0, 1]],
|
||||||
// [ "string", 42, { "key" : "value" }, [ 0, 1 ], "value", 0, 1 ],
|
[ "string", 42, { "key" : "value" }, [ 0, 1 ], "value", 0, 1 ],
|
||||||
// ["$..*", "$..[*]"]
|
["$..*", "$..[*]"]
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// select(
|
select(
|
||||||
// ["string", 42, { "key": "value" }, [0, 1]],
|
["string", 42, { "key": "value" }, [0, 1]],
|
||||||
// ["value", 0, 1],
|
["value", 0, 1],
|
||||||
// ["$.*.*", "$[*].*", "$.*[*]", "$[*][*]"]
|
["$.*.*", "$[*].*", "$.*[*]", "$[*][*]"]
|
||||||
// );
|
);
|
||||||
//
|
|
||||||
// done();
|
done();
|
||||||
// });
|
});
|
||||||
});
|
});
|
@ -125,7 +125,6 @@
|
|||||||
extern crate array_tool;
|
extern crate array_tool;
|
||||||
extern crate core;
|
extern crate core;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate indexmap;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
@ -2,7 +2,6 @@ use std::collections::HashSet;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use array_tool::vec::{Intersect, Union};
|
use array_tool::vec::{Intersect, Union};
|
||||||
use indexmap::IndexMap;
|
|
||||||
use serde_json::{Number, Value};
|
use serde_json::{Number, Value};
|
||||||
|
|
||||||
use parser::parser::*;
|
use parser::parser::*;
|
||||||
@ -1167,7 +1166,8 @@ impl SelectorMut {
|
|||||||
origin: &Value,
|
origin: &Value,
|
||||||
target: &mut Vec<&Value>,
|
target: &mut Vec<&Value>,
|
||||||
tokens: &mut Vec<String>,
|
tokens: &mut Vec<String>,
|
||||||
visited: &mut IndexMap<*const Value, Vec<String>>,
|
visited: &mut HashSet<*const Value>,
|
||||||
|
visited_order: &mut Vec<Vec<String>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
trace!("{:?}, {:?}", target, tokens);
|
trace!("{:?}, {:?}", target, tokens);
|
||||||
|
|
||||||
@ -1177,7 +1177,9 @@ impl SelectorMut {
|
|||||||
|
|
||||||
target.retain(|t| {
|
target.retain(|t| {
|
||||||
if std::ptr::eq(origin, *t) {
|
if std::ptr::eq(origin, *t) {
|
||||||
visited.insert(*t, tokens.to_vec());
|
if visited.insert(*t) {
|
||||||
|
visited_order.push(tokens.to_vec());
|
||||||
|
}
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
@ -1188,7 +1190,7 @@ impl SelectorMut {
|
|||||||
Value::Array(vec) => {
|
Value::Array(vec) => {
|
||||||
for (i, v) in vec.iter().enumerate() {
|
for (i, v) in vec.iter().enumerate() {
|
||||||
tokens.push(i.to_string());
|
tokens.push(i.to_string());
|
||||||
if _walk(v, target, tokens, visited) {
|
if _walk(v, target, tokens, visited, visited_order) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tokens.pop();
|
tokens.pop();
|
||||||
@ -1197,7 +1199,7 @@ impl SelectorMut {
|
|||||||
Value::Object(map) => {
|
Value::Object(map) => {
|
||||||
for (k, v) in map {
|
for (k, v) in map {
|
||||||
tokens.push(k.clone());
|
tokens.push(k.clone());
|
||||||
if _walk(v, target, tokens, visited) {
|
if _walk(v, target, tokens, visited, visited_order) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
tokens.pop();
|
tokens.pop();
|
||||||
@ -1209,14 +1211,21 @@ impl SelectorMut {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut visited = IndexMap::new();
|
let mut visited = HashSet::new();
|
||||||
|
let mut visited_order = Vec::new();
|
||||||
|
|
||||||
if let Some(origin) = &self.value {
|
if let Some(origin) = &self.value {
|
||||||
let mut tokens = Vec::new();
|
let mut tokens = Vec::new();
|
||||||
_walk(origin, &mut result, &mut tokens, &mut visited);
|
_walk(
|
||||||
|
origin,
|
||||||
|
&mut result,
|
||||||
|
&mut tokens,
|
||||||
|
&mut visited,
|
||||||
|
&mut visited_order,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.iter().map(|(_, v)| v.to_vec()).collect()
|
visited_order
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(&mut self) -> Result<&mut Self, JsonPathError> {
|
pub fn delete(&mut self) -> Result<&mut Self, JsonPathError> {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jsonpath-wasm"
|
name = "jsonpath-wasm"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
authors = ["Changseok Han <freestrings@gmail.com>"]
|
authors = ["Changseok Han <freestrings@gmail.com>"]
|
||||||
description = "It is Webassembly version of jsonpath_lib that is JsonPath engine written in Rust - Demo: https://freestrings.github.io/jsonpath"
|
description = "It is Webassembly version of jsonpath_lib that is JsonPath engine written in Rust - Demo: https://freestrings.github.io/jsonpath"
|
||||||
keywords = ["jsonpath", "json", "webassembly", "parsing", "rust"]
|
keywords = ["jsonpath", "json", "webassembly", "parsing", "rust"]
|
||||||
@ -14,10 +14,10 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
default = ["console_error_panic_hook", "wee_alloc"]
|
default = ["console_error_panic_hook", "wee_alloc"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cfg-if = "0.1.2"
|
cfg-if = "0.1"
|
||||||
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
|
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
|
||||||
console_error_panic_hook = { version = "0.1.1", optional = true }
|
console_error_panic_hook = { version = "0.1", optional = true }
|
||||||
wee_alloc = { version = "0.4.2", optional = true }
|
wee_alloc = { version = "0.4", optional = true }
|
||||||
|
|
||||||
jsonpath_lib = { path = "../" }
|
jsonpath_lib = { path = "../" }
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user