Expand description
§gron — make JSON greppable
Flatten a JSON document into discrete, greppable assignment lines, and
reconstruct it back — a Rust port of gron,
available both as a library and a gron CLI.
use serde_json::json;
let v = json!({ "user": { "name": "Tom", "tags": ["a", "b"] } });
let lines = gron::gron(&v);
assert_eq!(lines, "\
json = {};
json.user = {};
json.user.name = \"Tom\";
json.user.tags = [];
json.user.tags[0] = \"a\";
json.user.tags[1] = \"b\";
");
// …and back again.
assert_eq!(gron::ungron(&lines).unwrap(), v);Flat assignment lines are perfect for grep, diff, and sed over JSON.
Enums§
- Ungron
Error - An error produced while parsing gron lines in
ungron.
Functions§
- gron
- Flatten
valueinto gron assignment lines using the default rootjson. - gron_
with_ root - Flatten
valueinto gron assignment lines using a custom root identifier. - ungron
- Reconstruct a
Valuefrom gron assignment lines.