treek

Treek, like awk but for tree input. Take JSON or TOML or some other tree like input format and run code on bits of it.
git clone http://shtanton.xyz/git/repo/treek
Log | Files | Refs | README

README.md (554B)


      1 # treek
      2 
      3 Like awk but for trees.
      4 
      5 Currently supports only JSON.
      6 
      7 Currently implemented in go but once the spec is final I'll reimplement in C or something.
      8 
      9 # Examples
     10 
     11 #### Extract a value
     12 ```
     13 treek "path.to.value"
     14 ```
     15 
     16 #### Print full names of all people
     17 ```
     18 treek 'people.* {println($0.first_name + " " + $0.last_name)}'
     19 ```
     20 
     21 #### Print average age of all people
     22 ```
     23 treek 'people.*.age {total += $0; count += 1} {println(total / count)}'
     24 ```
     25 
     26 #### Print the first names of all the Johnsons
     27 ```
     28 treek 'people.($0.last_name=="Johnson").first_name'
     29 ```