pg-jsonl
An owned, streaming parser for property-graph JSON Lines (PG-JSONL): one JSON object per line describing a node or an edge.
Two dialects are accepted on every line, so files may mix them:
- the plain dialect
- Neo4j APOC
apoc.export.json
Identifiers may be JSON strings or numbers; they are kept as text. Property
values are rendered as text with the JSON type as a hint (string, int,
float, boolean, or json for arrays and objects); null properties are
skipped.
Why this crate
The PgJsonlStreamParser API processes one physical line at a time and keeps
nothing between lines but a counter, so memory stays bounded for large exports
and callers decide where records go. The convenience parse_pg_jsonl function
is available when collecting the complete result is appropriate.
The crate depends on no database driver, graph store, RDF model, or application
framework. The optional property-graph-model feature adds field-for-field
From conversions into that crate's PgNode / PgEdge.
Quick start
use parse_pg_jsonl;
let input = r#"{"type":"node","id":"alice","labels":["Person"],"properties":{"name":"Alice"}}
{"type":"edge","source":"alice","target":"bob","label":"KNOWS"}
"#;
let = parse_pg_jsonl?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Streaming large exports
use ;
let mut parser = new;
let mut edges = 0;
for line in r#"{"type":"node","id":"a"}
{"type":"edge","source":"a","target":"a","label":"SELF"}
"#.lines
assert_eq!;
# Ok::
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.