mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-25 01:12:17 +00:00
README.md - Webassembly
This commit is contained in:
parent
39e6466ea2
commit
c122fe18d3
40
README.md
40
README.md
@ -9,7 +9,45 @@ To enjoy Rust
|
||||
|
||||
## With Javascript (WebAssembly)
|
||||
|
||||
-
|
||||
|
||||
[Demo]: https://freestrings.github.io/jsonpath/
|
||||
|
||||
**(not yet published `jsonpath-wasm`)**
|
||||
|
||||
```javascript
|
||||
import * as jsonpath from "jsonpath-wasm";
|
||||
|
||||
//
|
||||
// data
|
||||
//
|
||||
let jsonString = "{\"a\" : 1}";
|
||||
|
||||
//
|
||||
// reuse a compiled jsonpath
|
||||
//
|
||||
let template = jsonpath.compile("$.a");
|
||||
// read as json string
|
||||
template(jsonString)
|
||||
// read as json object
|
||||
template(JSON.parse(jsonString));
|
||||
|
||||
//
|
||||
// reuse a json
|
||||
//
|
||||
|
||||
// as json string
|
||||
let reader1 = jsonpath.reader(jsonString);
|
||||
reader1("$.a");
|
||||
|
||||
// as json object
|
||||
let reader2 = jsonpath.reader(JSON.parse(jsonString));
|
||||
reader2("$.a");
|
||||
|
||||
// read every time
|
||||
jsonpath.read(JSON.parse(jsonString), "$.a");
|
||||
jsonpath.read(jsonString, "$.a");
|
||||
```
|
||||
|
||||
|
||||
## On Shell
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user