Part II of a series about working with web APIs.
JSON (JavaScript Object Notation) is described at http://www.json.org/. It is a simple data interchange language which depends on two fundamental data structures:
Object: An unordered set of name / value pairs
Objects are delineated by curly brackets. Each name /value pair is separated by a colon, and pairs are separated by a comma.
Array: An ordered collection of of values
Values in an array can be almost any data type, including string, number, array, true, false, null, or object.
Arrays are delineated by brackets. Array elements are separated by a comma.
So, when we’re passing in the authorization credentials for our Brightpearl API, we’re passing in a nested set of name/value pairs as a single object:
{
apiAccountCredentials:{
emailAddress:”myname@mydomain.com”,
password:”mypassword”
}
}
Brightpearl returns query results as JSON as well. The first part of a the result is the description of the data….the second part is the actual data. (See Part 1 of this series for the full example).
The JSON.org page has links to JSON libraries for a plethora of programming languages and databases. While not listed on the page there is also a JSON module for FileMaker. For mySQL there is a discussion of a couple ways of formatting the output of a mySQL query into JSON using Ruby, PHP, or using PHPmyAdmin.
My JSON module for FileMaker is now listed at json.org.
LikeLike