-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject-Arrays.jsonc
74 lines (58 loc) · 2.29 KB
/
Object-Arrays.jsonc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
//? Object Arrays - Json
/* In Json, object arrays are used to represent ordered collections of objects, which
It is very useful for storing and retrieving multiple related data items. Here you have a
example of how to create object arrays in Json. */
"objects" : [
{
"name": "John",
"age": 30,
"city": "Exampleville"
},
{
"name": "Mary",
"age": 28,
"city": "Exampleville"
},
{
"name": "Peter",
"age": 35,
"city": "Another city"
},
// Object Arrays - Json
[
{
"name": "John",
"age": 30,
"city": "Exampleville"
},
{
"name": "Mary",
"age": 28,
"city": "Exampleville"
}
]
]
// In the example above, we have an array that contains three objects. Each object represents
// information about a person, including their name, age, and city.
//? Here are some key things to keep in mind when working with arrays of objects in Json.
//** 1. **Syntax:**
/* Arrays are defined using square brackets (`[]`) and objects are separated by commas. /*
//* 2. **Objects in the array:**
Each element within the array is a complete Json object with its own key-value pairs. /*
//* 3. **Access to elements:**
/* You can access individual elements within the array using indexes. The first element
has an index of 0, the second an index of 1, and so on. For example, to access the
second object in the array, you would use `[1]`. */
//* 4. **Iteration:**
/* You can loop through an array of objects to process each element separately.
Depending on the programming language you are using, this is done differently. */
// For example, in JavaScript, you can access array elements and their properties as follows
// manner.
// Access the name of the first object
// Iterate through the array and print the names
/* Arrays of objects in Json are a common way to represent related sets of data, and
They are widely used in information exchange in web applications and data systems
structured. You can perform read, write, modify, and delete operations on objects on
arrays similarly as you would on individual Json objects. */
}