Import JSON data into Google Sheets

前端 未结 4 1357
北荒
北荒 2021-01-30 05:50

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

相关标签:
4条回答
  • 2021-01-30 05:54

    Apps script is (pretty much) just Javascript; plain-old JSON.parse is your best option for parsing JSON into an object representation.

    You can also use JSON.stringify to serialize an object into a string representation.

    0 讨论(0)
  • 2021-01-30 05:58

    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")
    
    0 讨论(0)
  • 2021-01-30 06:06

    JSON.parse

    For those who are seeing this in 2011+, as pointed out by Henrique Abreu at the Google support forum, Utilities.jsonParse is/will be deprecated. As you can see from the thread, there's a bug with this function that it does not work when your keys are numbers, ie "1234".

    As suggested, you should be using JSON.stringify/parse.

    0 讨论(0)
  • 2021-01-30 06:06

    Use this gist : https://gist.github.com/varun-raj/5350595a730a62ca1954

    Replace

    http://example.com/feeds?type=json
    

    with your JSON url

    Add your entities here

    rows.push([data.id, data.name,data.email]);
    
    0 讨论(0)
提交回复
热议问题