The data table toJSON method returns a Json object in its string format. If you want to get the object for that string you can use eval(jsonString) or the safer method JSON.parse(jsonString)
ChartMan On Fri, Dec 17, 2010 at 11:29 PM, Peppi <[email protected]> wrote: > Hi, > > I'm using the Visualization API to pull data from a Google > Spreadsheet. I then need to turn the DataTable that is returned into > JSON. I tried using the toJSON() function, but after I do this, I > can't seem to access any members of the JSON object. I don't think > this function works, and I don't really want to use it anyway. I would > prefer to use the labels (column headings) as property names. > > I want to be able to create a JSON object with the following format, > but startTime, endTime etc. would change depending on the spreadsheet > that I am reading from. I don't want this to be tied to a specific > spreadsheet or format. > > { > "rows": [ > { > "startTime": "8:30 AM", > "endTime": "2:00 PM", > "title": "CASE District VI Board Meeting", > "location": "Pershing Place North" > } > { > "startTime": "8:30 AM", > "endTime": "2:00 PM", > "title": "CASE District VI Board Meeting", > "location": "Pershing Place North" > } > ] > } > > How can I create this from the DataTable? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-visualization-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
