Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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
    ...


This is called gron, I prefer it for reading JSON with a lot of nesting.

https://github.com/tomnomnom/gron


This is really cool. Gives you much of what jq does without having to remember jq syntax.


This is amazing!


Augtool from the Augeas project too. (As well as the mentioned gron)


example

   $ 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 ...


I 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.


I 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 /


The example was a good idea, thanks! I added it




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: