Skip to content

Instantly share code, notes, and snippets.

@digitalicarus
Last active December 19, 2015 14:09
Show Gist options
  • Select an option

  • Save digitalicarus/5967234 to your computer and use it in GitHub Desktop.

Select an option

Save digitalicarus/5967234 to your computer and use it in GitHub Desktop.
| prettyPrintJSON
curl http://freegeoip.net/json/ | node -e "d='';s=process.stdin;o=process.stdout;j=JSON;s.on('data',function(c){d+=c;});s.on('end',function(){d=j.parse(d); console.log(j.stringify(d,null,30))});"
#== pretty print json
$ alias tojson="node -e \"d='';s=process.stdin;o=process.stdout;j=JSON;s.on('data',function(c){d+=c;});s.on('end',function(){d=j.parse(d); console.log(j.stringify(d,null,30))});\""
$ curl -s http://freegeoip.net/json/ | tojson
{
"ip": "24.173.208.130",
"country_code": "US",
"country_name": "United States",
"region_code": "TX",
"region_name": "Texas",
"city": "Austin",
"zipcode": "",
"latitude": 30.2672,
"longitude": -97.7431,
"metro_code": "635",
"areacode": "512"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment