TechDoc: JSON and JSON libraries used

Posted on May 9, 2011

0


Basis

JSON looks like this:

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

Objects and variables are represented as string values organized in brackets.

Reasons to use JSON

Serialization and de-serialization of objects are one of the core aspects of the SmartSpaces framework.

Most if not all JSON libraries have a JSON serializer (making JSON out of a given object) and JSON de-serializer (injecting the JSON object definition into an object) which cuts out the need to build a parser yourself.

In other words: it simplifies my work and using JSON makes the framework portable to many other platforms than the ones I use (C#, Java and Flash/ActionScript).

Overview of JSON libraries

Goto Jscon.org and scroll down. For each language a set of possible libraries are listed.

ActionScript libraries

I intend to use:

  1. as3corelib JSON serializer / deserializer – In as3corelib by Mike Chambers (Adobe). This provides the basic
  2. JSON wrapper – Based on this blog post by Manish Jethani to serialize an object and inject a JSON object into a Flash Object

C# Library

For the C# SmartSpaces Client/Server I use:

  1. Json.NET – A .NET library usable in C#. By JamesNK.

Java Library

I have not made my choice yet. Options are:

  1. Jackson JSON processor – Seems to offer serialization and de-serializatrion and claims to be really fast and have zero dependecies. See the five minutes introduction for coders here.
  2. JSON simple – More info here. Serialization and de-serializatrion, claims to be fast.

Android Library

Android seems to – default – come with a JSON library.

  1. org.json – The JSON package embedded in Android
Advertisements
Posted in: techdoc