JSON – the Open Data Object

18th December 2013
CONTACT US

JSON, or JavaScript Object Notation, is a lightweight open standard format that uses human-readable text to transmit data objects in the form of pairs of attributes and values. It is used primarily to transmit data between a server and a web application as an alternative to formats and languages such as XML for lightweight, flexible formatting of data for Internet communication in a way that is both machine-readable and human-readable.

Let’s look briefly at how JSON can be used, how it compares to XML (Extensible Markup Language), and the role JSON can play as a lightweight format for information transport in Internet of Things and embedded applications. In an Internet-of-Things application, every “Thing” connected to the network should have an API that allows access to key data elements.

This data needs to be streamed at an appropriate rate over the Internet to a server directly, or to a gateway or other device in the local network. Near-real-time access to sensor data at the gateway or at the server allows contextual information derived from that data to be served up in a timely manner, so minimising network overheads is clearly valuable.

JSON

Although originally derived from the JavaScript scripting language, JSON is a language-independent data format and code for parsing and generating JSON data is readily available in a large range of programming languages, making it easy to get up and running with the language of your choice. JSON objects are human readable – they are basically freeform text documents. Whilst JSON objects contain rich information and are a highly flexible way to represent data, they are easy for programmers and database administrators to use.



XML is well established as a language of choice to describe structured data and to serialise objects, and various XML-based protocols exist to represent the same kind of data structures as JSON for the same kind of data interchange purposes. When data is encoded in XML, the result is typically larger than an equivalent encoding in JSON, mainly because of the presence of closing tags in XML.

While the API is a key consideration in implementing a RESTful solution for moving around and accessing your data, the format of the payload is also equally as important. XML is one traditionally popular language in these sorts of applications, but JSON is not as verbose as XML and does not contain detailed processing instructions. Being a more lightweight data interchange format, it is faster to use JSON to send bits of data, such as data from a sensor for example, around the Internet of Things.

JSON is promoted as a lower-overhead alternative to XML, providing similar data exchange capabilities with support for creation, reading and decoding of data in the real world with lower overhead. The increasing popularity of REST over SOAP in modern APIs also promotes greater use of and support for JSON as the preferred data exchange format, since you are no longer limited to only returning XML.

JSON-RPC is an RPC protocol built on JSON, as a replacement for XML-RPC or SOAP. It is a simple protocol that defines only a handful of data types and commands. JSON-RPC allows for notifications – information sent to the server that do not require a response – and for multiple calls to be sent to the server that may be answered out of order. This flexibility in choosing messaging options to get the data where it is needed with the priority that is needed in the most lightweight possible way is attractive in resource-constrained and bandwidth-constrained Internet-of-Things networks or embedded systems.

JSON1

Modern web browsers incorporate native JSON encoding and decoding, increasing performance due to the fact that functions no longer need to be parsed as well as eliminating potential security vulnerabilities where JSON is evaluated as Javascript. Native JSON is generally faster compared to the JavaScript libraries used in the past to parse JSON, as well as more secure.

As an example of JSON in use for an existing embedded Internet-of-Things solution, the “Razberry” platform. This adds the hardware required for the Z-wave wireless home automation protocol to the Raspberry Pi single-board computer, turning an inexpensive device into a Z-wave home automation gateway and exposing control of your home automation network via a JSON interface.

Furthermore Google BigQuery added support for JSON a few years ago, explicitly mentioning the potentially useful role of JSON in connecting data collected from sensor networks and the Internet of Things to BigQuery, bringing the power of Google’s Big Data manipulation expertise together with the Internet of Things and sensor networks as the sources for that Big Data.

JSON is one of many tools available in the Internet-of-things toolbox, and can easily be used with many applications. And here at the LX Group our engineers have an excellent understanding of the standards required for effective communciation between devices within Internet-of-things platforms, and are ready to integrate it with your new and existing products.

To get started, join us for a confidential discussion about your ideas and how we can help bring them to life – click here to contact us, or telephone 1800 810 124.

LX is an award-winning electronics design company based in Sydney, Australia. LX services include full turnkey design, electronics, hardware, software and firmware design. LX specialises in embedded systems and wireless technologies design.

Published by LX Pty Ltd for itself and the LX Group of companies, including LX Design House, LX Solutions and LX Consulting, LX Innovations.

Muhammad AwaisJSON – the Open Data Object

Have a project you’d like to discuss? Speak to someone today.

Add your email and we’ll keep you in the loop with our future developments.