8.13 Tutorials: JSON Protocol

The sources of this example is found under the Examples/AS2/21_pro_jsonExample folder.

» Introduction

JSON is a lightweight data exchange format that has recently become popular thanks to technologies such as AJAX.
It is particularly suited for serializing and deserializing ECMA-262/Javascript/Actionscript data structures in a compact, yet human-readable, form.

SmartFoxServer 1.5.0 introduces the ability to use JSON as a protocol for client/server communication: one of the main advantages of using JSON is the "compactness" of the format which usually allows a compression factor of 2 to 5 when compared to XML.

When compared to the raw, string-based protocol JSON is still slightly "bloated" but it allows to transfer any type of data structure between client and server just like XML without the same overhead. Because of this we recommend to use JSON instead of XML in your extension communication.

Refactoring old applications with the new protocol should take very little effort as you just need to change the type of protocol used in your server side calls and simply recompile your client application with the latest APIs.

For super-fast, realtime interaction it is still recommendable to use the string-based protocol.

» Conclusions

You will find the main source file in the it/gotoandplay/smartfoxserver/smartmessenger/Messenger.as class (starting from the example folder)
The server side extension is located in the sfsExtensions/messenger.as file.


doc index