
Understanding JSON and its usage in AWS
In this blog, we will discuss the tale of JSON (JavaScript Object Notation). You will find JSON a very useful tool while working with a lot of technologies. The most significant of them all is AWS itself. Hence JSON covers a great base of Scripting in AWS.
JSON General Structure
JSON is a lightweight way to share data among web applications or machines. It is easier for machines to parse the information when shared in JSON format. The main structure comprises of the following elements:
Empty JSON Object
{ }
JSON Object
The most basic element in the JSON script is a JSON Object. Which is encapsulated in curly brackets and contains properties in the form of Key and Value Pairs. These Key and Value Pairs simply point out the information that the web applications are looking for.
{
"Key" : "Value"
}
JSON Properties
JSON Properties have five types: String, Numeric, Float, Boolean and NULL. Multiple properties are separated by commas.
{
"StringKey" : "StringValue",
"NumericKeyElement": 18,
"FloatKeyElement": 3.14,
"BooleanKeyElement": True,
"EmptyKeyElement": NULL
}
JSON Arrays
JSON Arrays are a collection of JSON objects. The objects are separated by commas and are encapsulated in square brackets.
[
{
"Key" : "Value",
"Attribute" : "Value"
},
{
"Key" : "Value",
"Attribute" : "Value"
}
]
JSON Nested Objects and Arrays
You can also nest objects and arrays within each other and that opens endless options for you. You can nest an object within an object and an object in an array. And to confuse you more yes the vice versa. You can nest an Array in an object as well.
{
"NestedObject" :
{
"Name": "NestedObject"
},
"NestedArrayInObject":
[
"NestedObjectInArray" :
{
"Key": "Value"
},
"NestedObjectInArray" :
{
"Key": "Value"
}
]
}
A great number of AWS provided services can be configured using JSON. These services include: