Tuesday, May 24, 2016

Unix - View JSON format in terminal

I learning NodeJS and I play a lot with JSON formated data. It realy mess-up when you want to curl any JSON ouput into terminal. My solution is to use json package via npm :
$ sudo npm install -g json

Let's check some example :
$ curl -X GET "https://jakim-esolat.herokuapp.com/prayer-times?zone_id=JHR04&start_date=2016-05-24&end_date=2016-05-25" | json
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   407    0   407    0     0    352      0 --:--:--  0:00:01 --:--:--   352
{
  "metadata": {
    "generated_at": "2016-05-24 15:58:06",
    "total_result": 2,
    "zone": {
      "id": "JHR04",
      "name": "Batu Pahat, Muar, Segamat, Gemas"
    }
  },
  "data": [
    {
      "date": "2016-05-24",
      "imsak": "5:28",
      "subuh": "5:38",
      "syuruk": "6:59",
      "zohor": "13:08",
      "asar": "16:32",
      "maghrib": "19:14",
      "isyak": "20:28"
    },
    {
      "date": "2016-05-25",
      "imsak": "5:28",
      "subuh": "5:38",
      "syuruk": "6:59",
      "zohor": "13:08",
      "asar": "16:32",
      "maghrib": "19:14",
      "isyak": "20:28"
    }
  ]
}

2 comments:

  1. First is to thank you for all this informative posts you give us for free; i bet all of us are happy.
    Such a great idea of yours! You have been a big help for me. Thanks a lot. more post for interesting topic. Great!

    SAP training in Chennai

    ReplyDelete