jsonpath_lib
Rust
버전 JsonPath 구현이다. Webassembly
와 Javascript
에서도 역시 동일한 API 인터페이스를 제공 한다.
It is an implementation for JsonPath written in Rust
. it provide the same API interface in Webassembly
and Javascript
also.
Why?
To enjoy Rust!
API
- jsonpath-wasm library
- jsonpath-rs library
- javascript - jsonpath.select(json: string|object, jsonpath: string)
- javascript - jsonpath.compile(jsonpath: string)
- javascript - jsonpath.selector(json: string|object)
- javascript - alloc_json, dealloc_json
- javascript-wasm - examples
- jsonpath_lib library
- rust - jsonpath::select(json: &serde_json::value::Value, jsonpath: &str)
- rust - jsonpath::select_as_str(json_str: &str, jsonpath: &str)
- rust - jsonpath::select_as<T:
serde::de::DeserializeOwned
>(json_str: &str, jsonpath: &str) - rust - jsonpath::compile(jsonpath: &str)
- rust - jsonpath::selector(json: &serde_json::value::Value)
- rust - jsonpath::selector_as<T:
serde::de::DeserializeOwned
>(json: &serde_json::value::Value) - rust - examples
Simple time check - webassembly
Simple time check - native addon for NodeJs
With Javascript
jsonpath-wasm library
(not yet published jsonpath-wasm
)
// browser
import * as jsonpath from "jsonpath-wasm";
// NodeJs
const jsonpath = require;
jsonpath-rs library (Only NodeJS)
jsonpath-rs
is native addon for NodeJs
const jsonpath = require;
javascript - jsonpath.select(json: string|object, jsonpath: string)
let jsonObj = ;
let ret = ;
let a = jsonpath.;
let b = jsonpath.;
console.log;
javascript - jsonpath.compile(jsonpath: string)
let template = jsonpath.;
let jsonObj = ;
let ret = JSON.;
// 1. read as json object
console.log;
// 2. read as json string
console.log;
let jsonObj2 = ;
let ret2 = JSON.;
// 1. read as json object
console.log;
// 2. read as json string
console.log;
javascript - jsonpath.selector(json: string|object)
let jsonObj = ;
let ret1 = JSON.;
let ret2 = JSON.;
// 1. read as json object
let selector = jsonpath.;
console.log;
console.log;
// 2. read as json string
let selector = jsonpath.;
console.log;
console.log;
javascript - alloc_json, dealloc_json
(not supported in jsonpath-rs
)
wasm-bindgen은 Javascript와 Webassembly 간 값을 주고받을 때 JSON 객체는 String으로 변환되기 때문에, 반복해서 사용되는 JSON 객체를 Webassembly 영역에 생성해 두면 성능에 도움이 된다.
Since wasm-bindgen converts JSON objects to String when exchanging values between Javascript and Webassembly, it is helpful to create repeated Json objects in Webassembly area.
let jsonObj = ;
let path = '$..friends[0]';
let template = jsonpath.;
let selector = jsonpath.;
let ptr = jsonpath.;
if console.error; // `0` is invalid pointer
let selector2 = jsonpath.;
let ret1 =
let ret2 =
let ret3 = ;
let ret4 = ;
let ret5 = jsonpath.;
let ret6 = jsonpath.;
console.log;// true
jsonpath.;
With Rust (as library)
jsonpath_lib library
extern crate jsonpath_lib as jsonpath;
extern crate serde_json;
rust - jsonpath::select(json: &serde_json::value::Value, jsonpath: &str)
let json_obj = json!;
let json = select.unwrap;
let ret = json!;
assert_eq!;
rust - jsonpath::select_as_str(json: &str, jsonpath: &str)
let ret = select_as_str.unwrap;
assert_eq!;
rust - jsonpath::select_as<T: serde::de::DeserializeOwned
>(json: &str, jsonpath: &str)
let ret: Person = select_as.unwrap;
let person = Person ;
assert_eq!;
rust - jsonpath::compile(jsonpath: &str)
let mut template = compile;
let json_obj = json!;
let json = template.unwrap;
let ret = json!;
assert_eq!;
rust - jsonpath::selector(json: &serde_json::value::Value)
let json_obj = json!;
let mut selector = selector;
let json = selector.unwrap;
let ret = json!;
assert_eq!;
let json = selector.unwrap;
let ret = json!;
assert_eq!;
rust - jsonpath::selector_as<T: serde::de::DeserializeOwned
>(json: &serde_json::value::Value)
let json_obj = json!;
let mut selector = ;
let json = selector.unwrap;
let ret = vec!;
assert_eq!;
let json = selector.unwrap;
let ret = vec!;
assert_eq!;