_anomDiebolt_
10 years agoQrew Elite
How To Get JSON From API_DoQuery?
We just had our Mas Que Nada QuickBase User Group planing meeting last night and several presenters were concerned that their presentations might be too advanced for the expected audience. So I was asked me to share some introductory materials that would serve as a foundation to some of the talks. So this post deals with bringing you up to speed on getting JSON from your API_DoQuery API calls.
As you probably know QuickBase's API returns XML. Unfortunately, XML lost the data interchange war to JSON and developers are stuck with the burdensome task of converting the XML returned by the QuickBase API to JSON before they can do anything productive with the data. You may be shocked by this opinion but it is overwhelmingly true and common knowledge among web developers:
JSON: The Fat-Free Alternative to XML
http://www.json.org/xml.html
So here is a simple technique to turn your XML into JSON transparently as part of your API_DoQuery requests. Here is a simple application with three records consisting of three field [Name], [Age], and [Email]:
API_DoQuery Return JSON - List All
https://haversineconsulting.quickbase.com/db/bjgzmpcgs?a=q&qid=1
Here is the XML Response (Flat) that API_DoQuery&qid=1 would return:
http://pastie.org/10264183
and this the the JSON Response we want to work with:
http://pastie.org/10264186
Here is some simple code that will effectively convert the Flat XML Response to a JSON Response as part of the AJAX request:
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=395
In a nutshell the dataFilter setting is used to define a utility function XMLFlatToObj to convert the XML returned by API_DoQuery into JSON. See screenshot attached
If you master this simple concept you will be one step close to understating the some of the fantastic presentations at the Mas Que Nada QuickBase User Group Conference in Brazil.

As you probably know QuickBase's API returns XML. Unfortunately, XML lost the data interchange war to JSON and developers are stuck with the burdensome task of converting the XML returned by the QuickBase API to JSON before they can do anything productive with the data. You may be shocked by this opinion but it is overwhelmingly true and common knowledge among web developers:
JSON: The Fat-Free Alternative to XML
http://www.json.org/xml.html
So here is a simple technique to turn your XML into JSON transparently as part of your API_DoQuery requests. Here is a simple application with three records consisting of three field [Name], [Age], and [Email]:
API_DoQuery Return JSON - List All
https://haversineconsulting.quickbase.com/db/bjgzmpcgs?a=q&qid=1
Here is the XML Response (Flat) that API_DoQuery&qid=1 would return:
http://pastie.org/10264183
and this the the JSON Response we want to work with:
http://pastie.org/10264186
Here is some simple code that will effectively convert the Flat XML Response to a JSON Response as part of the AJAX request:
Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=395
In a nutshell the dataFilter setting is used to define a utility function XMLFlatToObj to convert the XML returned by API_DoQuery into JSON. See screenshot attached
If you master this simple concept you will be one step close to understating the some of the fantastic presentations at the Mas Que Nada QuickBase User Group Conference in Brazil.
