Fork me on GitHub

jsonfilter

Jsonfilter is a cli tool for filtering and selecting values from json objects.

Release
Getting Started

Binaries are available for x86 and amd64 flavors of Darwin and Linux

    wget -qO- https://github.com/benschw/jsonfilter/releases/download/0.1.1/jsonfilter-`uname`-`uname -m`-0.1.1.gz | \
      gunzip > /usr/local/bin/jsonfilter
    chmod +x /usr/local/bin/jsonfilter
          

Pretty up a json object

    
  curl -s "http://api.openweathermap.org/data/2.5/weather?units=imperial&q=Austin,Texas" | jsonfilter -pretty
  {
      "base": "cmc stations",
      "clouds": {
          "all": 48
      },
      "cod": 200,
      "coord": {
          "lat": 30.27,
          "lon": -97.74
      },
      "dt": 1.423154714e+09,
      "id": 4.671654e+06,
      "main": {
          "grnd_level": 1018.67,
          "humidity": 74,
          "pressure": 1018.67,
          "sea_level": 1044.98,
          "temp": 44.37,
          "temp_max": 44.37,
          "temp_min": 44.37
      },
      "name": "Austin",
      "sys": {
          "country": "United States of America",
          "message": 0.0261,
          "sunrise": 1.423142315e+09,
          "sunset": 1.423181483e+09
      },
      "weather": [
          {
              "description": "scattered clouds",
              "icon": "03d",
              "id": 802,
              "main": "Clouds"
          }
      ],
      "wind": {
          "deg": 352.5,
          "speed": 13.37
      }
  }

          

Filter a sub object

  curl -s "http://api.openweathermap.org/data/2.5/weather?units=imperial&q=Austin,Texas" | jsonfilter -json coord
  {"lat":30.27,"lon":-97.74}
          

Get a single value

  curl -s "http://api.openweathermap.org/data/2.5/weather?units=imperial&q=Austin,Texas" | jsonfilter main.temp
  44.37
          

More examples on the github project page