4 ms·
Could use an example of the database file and diffs. I have vague recollections of a tool that was similarly supposed to make JSON files diffable. IIRC it proc
by andreareina 6y ago
Could use an example of the database file and diffs.
I have vague recollections of a tool that was similarly supposed to make JSON files diffable. IIRC it procedurally built up the object, so {"foo": {"bar": "baz", "quux": [1, 2, 3]}} would be:
foo = {}
foo.bar = "baz"
foo.baz = []
foo.baz[0] = 1
...
- emmelaich 6y agoAugtool from the Augeas project too. (As well as the mentioned gron)
- emmelaich 6y agoexample $ augtool -r . --noautoload --transform "Json.lns incl /sirdb-example.json" <<EOF > print /files/sirdb-example.json/ > EOF /files/sirdb-example.json /files/sirdb-example.json/dict /files/sirdb-example.json/dict/entry[1] = "_owner" /files/sirdb-example.json/dict/entry[1]/string = "nouser" /files/sirdb-example.json/dict/entry[2] = "username" /files/sirdb-example.json/dict/entry[2]/string = "nouser" /files/sirdb-example.json/dict/entry[3] = "email" .... etc ...
- chousuke 6y agoI find it unfortunate that augeas is so magical. Or rather, the design of its interface is very surprising What's up with requiring "--noautoload"? What does "-r ." do? and the transform invocation starts with the seemingly magical "Json.lns" (where does it come from?) and appears to refer to a file at the root of the filesystem hierarchy? I'd probably use augtool more often myself, but its UI is seriously inscrutable.
- emmelaich 6y agoI agree, fwiw. I'm writing a little program to make this whole lot easier. Answers: by default, augtool loads all the lenses and scans the entire default filesystem (typically /etc); `--noautoload` prevents that. The -r is `--root`; specify the root as the current directory rather than /
- PowerfulWizard 6y agoThis is called gron, I prefer it for reading JSON with a lot of nesting. https://github.com/tomnomnom/gron https://github.com/tomnomnom/gron
- graderjs 6y agoThe example was a good idea, thanks! I added it