GoJSON is a command line utility to handle JSON serialised data. You can find the code here

What it does


Go Dev version

$ go get -u github.com/sarathsp06/gojson

Binray Release

download and use the binary as such for your platform

Tip: In unix move the binary to PATH

Key Syntax

  • Key is a set of . separated nested values
  • Can use 0-n numbers to refer to index in arrays
  • Can use lower:upper syntax to refer to a range of an array
  • Can use keys of inner objects directly on arrays or range of them. Eg: players.name where players is an array

Usage Examples

Getting a value
  • Get a string:
$ echo '{"name":{"first":"Sarath","last":"Pillai"}}' | gojson name.last
  • Get a block of JSON:
$ echo '{"name":{"first":"Sarath","last":"Pillai"}}'  | gojson name

  "first": "Sarath",
  "last": "Pillai"
  • Try to get a non-existent key:
$ echo '{"name":{"first":"Sarath","last":"Pillai"}}' | gojson names

  • Get an array value by index:
$ echo '{"people":[{"name":"saratha"},{"name":"syam"}]}' | gojson people.1.name                                               
  • Projection from a slice
$ echo '{"people":[{"name":"saratha"},{"name":"syam"},{"name":"singh"},{"name":"ping"}]}' | gojson people.2:.name
  • Slice of array
$ echo '{"people":[{"name":"saratha"},{"name":"syam"},{"name":"singh"},{"name":"ping"}]}' | gojson people.2:5    
    "name": "singh"
    "name": "ping"

Build Status
Build Status