Reputation: 79
I have json data in this format
{
"jobstatus": [
{
"dateAndTime": "Nov 19, 2013 12:20:00 UTC",
"jobId": "TCC_tfc",
"userId": "admin",
"status": "Completed",
"jobType": "Excel Upload"
}
]
}
i am trying to create google spreadsheet in google docs with this data. There can be multiple rows. So how to insert my json into created spreadsheet? Maybe I should use google docs api?
Upvotes: 1
Views: 3392
Reputation: 36
the first think you have to do is declarate your data as JSON variable with the comand var jobs = JSON.parse(x);
where x is your piece of JSON.
I don't know if you know how to parse a JSON, but is very easy:
jobs.jobstatus.dateAndTime -> gives you "Nov 19, 2013 12:20:00 UTC"
and so for the other fields.
then to fill the google table (after link the right library) as you can see in this link Google Visualization API Reference you have to declarate new google table variable:
var data = new google.visualization.DataTable();
and fill this with your data taken from your JSON variable like:
data.addRows(["datetime",jobs.jobstatus.dateAndTime],
['jobId', jobs.jobstatus.jobId],
['userId', jobs.jobstatus.userId],
['status', jobs.jobstatus.status],
['jobType', jobs.jobstatus.jobType]
]););
This will be done for each row and each columns.
Upvotes: 2