- Azure Resource Manager Templates Quick Start Guide
- Ritesh Modi
- 768字
- 2021-07-02 12:59:31
A brief primer on JSON
JavaScript Object Notation (JSON) is a lightweight data-representation and interchange format. It is a text-based and human-readable format that is easy to read, comprehend, and update. Many people think of JSON as a programming language or a markup language; however, it is neither. It is a pure representation of data in text format.
Prior to JSON, XML was the preferred data-exchange format and JSON has few similarities with it. Like XML, JSON is self-describing. It is quite easy to understand the intent of a JSON document by just reading through it. Also, like XML, it can create complex as well as nested objects. It is hierarchical, and objects can be composed of child objects and arrays. However, the similarities end here. JSON documents are terser and much more compact compared to XML documents. As a result, they are also much more reader-friendly. The data in XML documents is all string-based, however, in JSON, data can have types that make it easier to parse and validate them. The XML syntax is quite verbose compared to JSON.
JSON is supported by almost all programming languages and it provides SDKs to generate as well as read them intuitively.
There are a few limitations when it comes to JSON documents. They do not have any schema definition and documents do not have any fixed specification associated to them. In effect, there are no parsers or facilities to validate that a JSON document adheres to a certain specification.
A simple JSON document is shown here:
“customer” : {
“customerId”: 1,
“firstName”: “ritesh”,
“lastName”: “Modi”,
“isRepeatCustomer”: true,
“address”: {
“streetName”: “10, Park Street”,
“city”: “Mumbai”,
“Country”: “India”
},
“productsOrdered”: [“IPhone”, “TShirt”]
}
Readers will notice that this JSON document is quite easy to read and comprehend. The basic JSON syntax comprises name-value pairs, where the name part is always decorated in double-quotes. Also, as a practice, the name part of the name-value pair follows the camel-casing naming standard. Each name is followed by a colon, :, and subsequently followed by the value part. Each name-value pair is separated using a comma: ,.
A JSON document starts with a left curly bracket, {, and ends with a right curly bracket: }. A JSON value can hold values of numbers, strings, Boolean, objects, and array data types:
- Strings: Strings are a sequence of continuous characters and always enclosed within double quotes. In the preceding example, India is a string value assigned to Country. "Country": "India"; since double-quotes are special characters in JSON, they need to be escaped if they are part of the value. For example: "/"India/"" will have an output of "India" assigned to the name element instead of just India without quotes.
- Numbers: JSON supports multiple data types related to numbers, including integers, scientific, and real numbers.
- Boolean: JSON supports true and false as Boolean values. They are never enclosed within quotes.
- Null: JSON also supports Null as a value. It means nothing is assigned to the name element.
- Objects: JSON also has a concept of an object. An object is a collection of key-value pairs enclosed within left curly brackets, {, and right curly brackets, }. Objects can be nested; that is, an object can contain another object as a child object. The customer document shown before in this section is an example of a JSON object.
- Arrays: JSON arrays start with left square brackets, [, and end with right square brackets, ]. JSON arrays contain name-value pairs separated by a comma. They can also contain a set of values. productsOrdered in the previous example was an example of JSON arrays.
ARM templates support the following additional objects:
- SecureString: A secure string is similar to a native JSON string; the difference is that the ARM templates runtime ensures that these values are never written in log files. These values are not visible on the Azure portal. This datatype is used to pass credentials, keys, and secrets that should not be visible to anyone.
- SecureObject: A secure object is similar to native JSON arrays and objects. Again, these values are not visible in Azure portal and log files and are used to pass arrays and objects as secrets to ARM templates.
- 電腦組裝與系統安裝
- Linux設備驅動開發詳解(第2版)
- Learning Windows Server Containers
- Kubernetes網絡權威指南:基礎、原理與實踐
- Haskell Financial Data Modeling and Predictive Analytics
- PLC控制系統應用與維護
- Linux網絡內核分析與開發
- Alfresco 4 Enterprise Content Management Implementation
- 數據中心系統工程及應用
- Dreamweaver CS5.5 Mobile and Web Development with HTML5,CSS3,and jQuery
- 注冊表應用完全DIY
- 一學就會:Windows Vista應用完全自學手冊
- Social Data Visualization with HTML5 and JavaScript
- OpenSolaris設備驅動原理與開發
- 應急指揮信息系統設計