Last Updated: February 25, 2016
·
1.02K
· 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

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside