JSON

The other day in response to a question in the KVMLIST I spent some looking into JSON, as I haven’t used it before for data exchange.

I’ll say that I actually like JSON quite a bit, due to its simplicity, and its structure — structured name/value pairs. For example from the JSON.org page:

An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

See a good comparisson of JSON vs. XML.

See a JSON parser Java source code.

See the rest of JSON at the JSON.org page.

That said, JSON doesn’t seem to support a clear or a good way to represent binary data, such as the images that you want to transport.

In response to the above sentence, Roger Riggs responded:

I think I would lean towards JSON, it is easy to produce and consume and is flexible and extensive in almost any platform.

But for binary data like images, I would suggest just putting the URL of the image into the JSON structure. That will allow a separate mechanism for retrieval that can more easily support caching and asynchronous retrieval and local storage.

Great idea to decouple binary data via a URL!

ceo