Spry JSON Primer

One of formats of data that Spry accepts is JSON. This document will present an overview of setting up JSON for use with Spry. It will have tips and tricks for generating and using JSON for Spry.

What is JSON?

JSON stands for JavaScript Object Notation. This is a lightweight, flexible yet strict method of storing and transmitting data. Flexible in that the user can create the format and names in any way they please; strict in the sense that JSON has a strict set of rules for structure.

Basic JSON code looks like this:

"firstName": "Jason",
"lastName": "Jones",
"address": {
"city": "San Francisco, CA",
"zip": 94121,
"address": "444 Columbus Ave"
"email": [

Let's break this down. A JavaScript object is a series of name/value pairs, written in a structured way. The basic structure is:


Data Types

JSON supports the common data types listed below. Each has a set of rules for structure.

In JavaScript "true" and "false" are pre-defined keywords. To send a true simply send the word true:

To send a false, send the word false:

In JSON, strings must be delimited by the double quote characters. For a list of what characters are allowed and what characters must be escaped, checkout the JSON web site.
"address": "444 Columbus Ave"
JSON support for numbers includes positive integers:
"zip": 94121

Negative integers:

total points": -123



Scientific notation:

"atoms per mole":-6.023e+23
Arrays are delimited by square brackets. Each item within the array is separated by a comma. Arrays can contain *all* supported JSON constructs.
"values":[ 1, false, "test", [ 2, 3 ], { "test": 1 } ]

In the example above describes an array of 5 elements which include a number, boolean, string, array, and object.

Objects are delimited by braces. Objects contain zero or more property/value pairs separated by commas:
{ "count": 2, "results": [ 2, 3 ] }
The example above describes an object with two properties on it, the "count" and "results" property. The "count" property has an integer value of 2, and the "results" value is an array.

In JavaScript, null is a pre-defined object. To send a null in JSON notation, you simply send the word null:


More Reading



Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.