What is JSON and How Is It Used?

I’m not a developer, and I’m guessing if you’re a regular Petri IT Knowledgebase reader, neither are you. But as a system administrator, you will probably have come across XML, or Extensible Markup Language, which is used for defining documents in such a way that mere mortals can also read and understand the format. And while sysadmins are more familiar with XML as a means of defining documents, it’s also commonly used for defining data structures used by web services.

JSON versus XML

JSON stands for JavaScript Object Notation, and one of the primary reasons to use it over XML is that data can be loaded asynchronously more easily than using XML, so JSON is finding popularity in web services. JSON is more lightweight than XML because it mainly contains the data that needs to be transferred, rather than a lot of markup used to define the structure of the data. JSON is used to serialize data, or in other words convert the data into a format that can be stored. For example, it’s possible to present JSON data as a JavaScript object, or simply serialize and deserialize the data.

Additionally, JSON helps AJAX developers — think JavaScript and XML — overcome Same Origin Policy restrictions where code from one domain can’t request data from another. For example, if you want to pull data from a third-party web service, JavaScript Object Notation with Padding (JSONP) can be used to retrieve the data that usually has a function call wrapped around it.

Azure Resource Manager templates

So why am I writing about JSON on Petri? Because as a system administrator, sooner or later you’re likely to come across JSON, and understanding how it differs from XML might be useful. But the reason I was compelled to write this piece is that Azure Resource Manager templates use JSON, and for a complete understanding of this technology, an overview of JSON has value.

There will be more articles on Petri soon about how to use Azure Resource Manager, but for the time being, if you haven’t come across it yet, Resource Manager is the new default method in the preview management portal for deploying applications in Azure, and that includes virtual machines. With the help of JSON-defined templates, entire applications can be deployed in the cloud, and more easily than relying on other automation methods, such as the Azure cmdlets for PowerShell.