Alex Rivera | Logout

Import JSON data into Google Sheets

Asked 2010-04-17T15:50:52.137
32

I am pulling data from a web service and it is formatted as JSON. I am writing a Google Apps Script for Google Sheets that will populate the data for me. My problem is, I can't seem to get it to parse out.

Doing:

var dataset = myJSONtext;
Browser.msgbox(dataset.item[0].key); 

errors out, saying:

item[0] is not defined.

Is there some built in way I should be doing this?

Edit
Report

1 Answer

18

A 2013 update -- Check out the ImportJSON library at

http://blog.fastfedora.com/projects/import-json

"ImportJSON imports data from public JSON APIs into Google Spreadsheets. It aims to operate similarly to how the native Google Spreadsheet functions ImportData and ImportXML work."

Code available here and he has submitted it to the Script Gallery: https://raw.github.com/fastfedora/google-docs/master/scripts/ImportJSON/Code.gs

Example usage: After putting the code in your Google spreadsheet's Script Editor, then paste this in cell A1 of the sheet:

=ImportJSON("http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json", "/feed/entry/title,/feed/entry/content",               "noInherit,noTruncate,rawHeaders")
answered 2013-04-23T19:05:37.983

Your Answer