Hi Sergey, Thanks for getting back to me. I definitely need to get a dataTable out of my JSON so it looks like I have some work to do on this front. Regards, Nick
On Wed, Feb 17, 2016 at 4:08 PM, 'Sergey Grabkovsky' via Google Visualization API <[email protected]> wrote: > Okay, so first of all, the google.visualization.Query expects the response > to be jsonp, which means that it's a JSON object passed to a function, i.e. > "processResponse({"abc": 123})". Setting the sendMethod option > <https://developers.google.com/chart/interactive/docs/reference#constructor_10> > to 'xhr' should make it work (assuming there are no cross-domain issues). > > However, there is another problem. google.visualization.Query only works > with Google Charts Data Sources, as described here > <https://developers.google.com/chart/interactive/docs/dev/implementing_data_source>. > As you can hopefully see from the "Response Format" documentation > <https://developers.google.com/chart/interactive/docs/dev/implementing_data_source#response-format>, > the query expects a number of things to exist in the response JSON, such as > a "reqId" and "status". Another thing is that it expects a DataTable to be > included in the response (assuming that no error has occurred). > > Your DataSource's response obviously does not include any of these things, > and will fail again for these reasons after you fix the first issue (with > the Query expecting a jsonp response). Your best bet would probably be to > use $.ajax <http://api.jquery.com/jquery.ajax/> to fetch your json, and > some custom JavaScript code to coerce it into a DataTable. > > On Wed, Feb 17, 2016 at 10:18 AM Nick Dunbar <[email protected]> > wrote: > >> Hi Sergey, >> >> I am using google.visualization.Query with the following code: >> >> var query = new google.visualization.Query(' >> https://api.stlouisfed.org/fred/series?series_id=GNPCA&api_key=d804714094ebfac5b67efd8b1e3da28f&file_type=json' >> ); >> query.send(handleQueryResponse); >> function handleQueryResponse(response) { >> if (response.isError()) { >> alert('Error in query: ' + response.getMessage() + ' ' + >> response.getDetailedMessage()); >> return; >> } >> >> (note that the API is the Federal Reserve which requires a dedicated API >> key) >> >> I also have the jQuery API loaded, and I know there is a jQuery.parseJSON >> method but I don't know how it works. >> >> Thanks for your assistance, >> >> Nick >> >> On Wed, Feb 17, 2016 at 2:54 PM, 'Sergey Grabkovsky' via Google >> Visualization API <[email protected]> wrote: >> >>> Hi Nick, >>> >>> Are you trying to use the google.visualization.Query to load the JSON >>> file? Or are you using XHR or jQuery to load it? >>> >>> On Wed, Feb 17, 2016 at 9:51 AM Nick Dunbar <[email protected]> >>> wrote: >>> >>>> Any thoughts on this one? I appreciate this is XML but I am trying to >>>> avoid having to learn Python to do this properly. >>>> >>>> All help appreciated. >>>> Nick >>>> >>>> On Mon, Feb 15, 2016 at 5:07 PM, <[email protected]> wrote: >>>> >>>>> Hi, >>>>> >>>>> I'm using the Query/response method to download data from an API >>>>> source into a dataTable, but I get "SyntaxError: Unexpected token ':'. >>>>> Parse error." followed by a timeout alert. However, in the console, the >>>>> downloaded data (pasted below) appears ok to me. Can anyone spot what the >>>>> problem is, and how to fix it? >>>>> >>>>> Thanks, >>>>> Nick >>>>> >>>>> >>>>> { >>>>> "realtime_start": "2016-02-15", >>>>> "realtime_end": "2016-02-15", >>>>> "seriess": [{ >>>>> "id": "GNPCA", >>>>> "realtime_start": "2016-02-15", >>>>> "realtime_end": "2016-02-15", >>>>> "title": "Real Gross National Product", >>>>> "observation_start": "1929-01-01", >>>>> "observation_end": "2014-01-01", >>>>> "frequency": "Annual", >>>>> "frequency_short": "A", >>>>> "units": "Billions of Chained 2009 Dollars", >>>>> "units_short": "Bil. of Chn. 2009 $", >>>>> "seasonal_adjustment": "Not Seasonally Adjusted", >>>>> "seasonal_adjustment_short": "NSA", >>>>> "last_updated": "2015-07-30 09:03:15-05", >>>>> "popularity": 25, >>>>> "notes": "BEA Account Code: A001RX1" >>>>> } >>>>> ] >>>>> } >>>>> >>>> -- >>>>> You received this message because you are subscribed to a topic in the >>>>> Google Groups "Google Visualization API" group. >>>>> To unsubscribe from this topic, visit >>>>> https://groups.google.com/d/topic/google-visualization-api/dmBdIMqe3_U/unsubscribe >>>>> . >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>> >>>> >>>>> To post to this group, send email to >>>>> [email protected]. >>>>> Visit this group at >>>>> https://groups.google.com/group/google-visualization-api. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/google-visualization-api/f503f439-d42d-4f03-883d-34beb59fe529%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/google-visualization-api/f503f439-d42d-4f03-883d-34beb59fe529%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Google Visualization API" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to >>>> [email protected]. >>>> Visit this group at >>>> https://groups.google.com/group/google-visualization-api. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/google-visualization-api/CAO5F7cupLWhL4faj6icb0KOa-qOTdEC_ygS_iOGq7cLqxWE1dQ%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/google-visualization-api/CAO5F7cupLWhL4faj6icb0KOa-qOTdEC_ygS_iOGq7cLqxWE1dQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >>> >>> *[image: unnamed.gif]• Sergey Grabkovsky• Software Engineer• Google, >>> Inc• [email protected] <[email protected]>* >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Google Visualization API" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/google-visualization-api/dmBdIMqe3_U/unsubscribe >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> To post to this group, send email to >>> [email protected]. >>> Visit this group at >>> https://groups.google.com/group/google-visualization-api. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/google-visualization-api/CAEwwup6-ufv2YLJir0gG%3DnW3c2wcY2k_05EE9WTSL-bx_foKKQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/google-visualization-api/CAEwwup6-ufv2YLJir0gG%3DnW3c2wcY2k_05EE9WTSL-bx_foKKQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >> >> >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Visualization API" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to >> [email protected]. >> Visit this group at >> https://groups.google.com/group/google-visualization-api. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-visualization-api/CAO5F7cvruP5n%2BwHWHRy_UMAGgsDxpAMvbp_JNjnDVqPzkcfBNw%40mail.gmail.com >> <https://groups.google.com/d/msgid/google-visualization-api/CAO5F7cvruP5n%2BwHWHRy_UMAGgsDxpAMvbp_JNjnDVqPzkcfBNw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > > *[image: unnamed.gif]• Sergey Grabkovsky• Software Engineer• Google, Inc• > [email protected] <[email protected]>* > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Google Visualization API" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/google-visualization-api/dmBdIMqe3_U/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > https://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/CAEwwup6sWxyG0tSDrD7%2Bikvkp2zaYoYmDM_ma7K2yFrrW6k_JQ%40mail.gmail.com > <https://groups.google.com/d/msgid/google-visualization-api/CAEwwup6sWxyG0tSDrD7%2Bikvkp2zaYoYmDM_ma7K2yFrrW6k_JQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAO5F7cuNzdK%2Bz-Z3uZyVYSRWXxdQ-B-PzZtSWgEmeNrjeFPoWw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
