Last Updated: February 25, 2016
·
823
· paksoy

Json Scripting in the Chrome Dev Console

Piping JSON from curl into shell scripts? There's no need for that, You can parse and manipulate JSON right in the browser without any plugins. Hit the JSON URL you want to script, ppen up the Chrome Dev Console and type in the following magic incantation:

JSON.parse($$('pre')[0].innerHTML)

This will return a JavaScript object that represents the data you're looking at!

For example, you can open up the Yahoo Weather API JSON endpoint. and inspect the contents of the response like any old JavaScript object:

ret = JSON.parse($$('pre')[0].innerHTML)
ret.query.results.channel.item.forecast[0].text