Comment by kerblang

2 months ago

I made a silly groovy script called "mommyjson" that doesn't try to preserve JSON formatting but just focuses on giving you the parentage (thus the name) including array indexes, object names, etc., all on the same line, so that when you find something, you know exactly where it is semantically. Not gonna claim that everybody should use it or that it cures insomnia cancer & hangnails, but feel free to borrow it:

https://github.com/zaboople/bin/blob/master/mommyjson.groovy

(btw I would happily upvote a python port, since groovy is not so popular)

This is good! There are a number of these, so it seems like it's definitely somthing people want. The most popular of which I think is gron[0]. My own is jstream[1]. One tiny point of friendly feedback: you may want to consider adding an example usage/output so folks can see what it does literally.

[0] - https://github.com/tomnomnom/gron [1] - https://github.com/ckampfe/jstream

  • Late reply: Ah thanks

    Being a lazy slob, I never saw fit to make a dedicated repo (or even, directory) so I have no place for a readme. After all the whole thing fits in one script.

    Gron is a great name and the output looks pretty good... I like the idea of outputting perfectly valid javascript (with semicolons, even...)

    Let's see if HN will format this sample output from mommyjson right:

        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   description: Optimized grid-enabled parallelism
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   taskId: T368
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo: {
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   id: E00200
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   name: Timothy Mullins
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   skills: {
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   skills:   primary: C++
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   skills:   experience: {
        employees:   [199]   profile:   projects:   [0]   tasks:   [0]   assignedTo:   skills:   experience:   years: 10