Array vs Object – JSON is one of the most popular data formats. However, the creation of such an object is done according to some rules. These rules depend on the original data type. In this article we will introduce you to the conversion of some JSON data types (Array vs Object).
What is JSON anyway?
You can best compare the JSON data structure to XML and YAML, only it’s simpler and more compact.
What are the basic rules?
Data Formats – JSON Array vs Object
Basically, you can have different data types included in JSON.
Your JSON value can take one of the following allowed types.
A JSON object represents the basic form of a JSON text. With this you can accept any data type that is suitable for inclusion in JSON.
JSON Array vs Object – It is possible to include an array. Arrays can contain objects, strings, numbers, arrays and boolean. You can include arrays as shown schematically below, enclosed with two square brackets.
In this way, you can further and further nest the individual data types with each other and thus easily create any number of hierarchy levels. For example, object attributes can consist of arrays, or arrays can contain multiple objects.