Streamson Lib
Rust library to handle large JSONs.
Note that it doesn't fully validates whether the input JSON is valid. This means that invalid JSONs might pass without an error.
Strategies
Strategy | Processes data | Buffers matched data | Nested matches | Uses handlers |
---|---|---|---|---|
Trigger | No | Yes | Yes | Yes |
Filter | Yes | No | No | No |
Extract | Yes | Yes | No | No |
Convert | Yes | Yes | No | Yes |
Trigger strategy
It doesn't actually perform parses json into data. It just takes JSON parts and triggers handlers when a path is matched.
Filter strategy
It actually alters the JSON. If the path is matched the matched part should be removed from output json.
Extract strategy
Only extracts matched data, nothing else.
Convert strategy
Alters the JSON by calling convert functions to matched parts.
Matchers
Structures which are used to match a part of JSON.
Simple
It matches path in JSON. For example:
Simple path {"users"}[0]{"name"}
would match "carl"
.
Simple path {"users"}[]{"name"}
would match "carl"
and "bob"
.
Simple path {}[0]{"name"}
would match "carl"
and "admins"
.
Simple path ??{"name"}
would match "carl"
, "bob"
, "admins"
and "staff"
.
Simple path *{"name"}
would match "carl"
, "bob"
, "admins"
and "staff"
.
Depth
Matches depth in JSON path. It has min length and max length ranges (max is optional).
All
It matches any JSON element. It is used only for some specific purpuses (such as JSON analysis).
Combinator
Wraps one or two matchers. It implements basic logic operators (NOT
, OR
and AND
).
Examples
Trigger
use ;
use ;
use *;
let mut trigger = new;
let handler = new;
let matcher = new.unwrap;
trigger.add_matcher;
let mut buffer = ;
let mut input = "<input data>".as_bytes;
while let Ok = input.read
Filter
use ;
use *;
let mut filter = new;
let matcher = new.unwrap;
filter.add_matcher;
let mut buffer = ;
let mut input = "<input data>".as_bytes;
while let Ok = input.read
Extract
use ;
use *;
let mut extract = new;
let matcher = new.unwrap;
extract.add_matcher;
let mut buffer = ;
let mut input = "<input data>".as_bytes;
while let Ok = input.read
Convert
use ;
use ;
use *;
let mut convert = new;
let matcher = new.unwrap;
convert.add_matcher;
let mut buffer = ;
let mut input = "<input data>".as_bytes;
while let Ok = input.read
Traits
Custom Handlers
You can define your custom handler.
use ;
;
Custom Matchers
You can define custom matchers as well.
use matcher;
;