-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject-Creation.jsonc
42 lines (31 loc) · 1.72 KB
/
Object-Creation.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
{
//? Object Creation - Json
/* In Json (JavaScript Object Notation), object creation is done by defining key-value pairs
inside braces `{}`. Each key-value pair consists of a key (a string) followed by a colon `:` and a
worth. Json objects can contain one or more key-value pairs. Here is an example of how to create a
Json object. */
"name": "John",
"age": 30,
"city": "Exampleville",
/* You can create more complex Json objects by nesting objects inside objects or including arrays like
values For example.*/
"person": {
"name": "John",
"age": 30,
"city": "Exampleville"
},
"friends": ["María", "Peter", "Anna"]
//? In this example, we have created a Json object with three key-value pairs:
// 1. `"name": "John"`: Here, "name" is the key and "John" is the value. The key is a string that
// acts as an identifier for the associated value.
// 2. `"age": 30`: The same structure applies here, where "age" is the key and 30 is the value.
// 3. `"city": "Exampleville"`: Again, the key is "city" and the value is "Exampleville".
//? In this example, we have a Json object that contains two key-value pairs:
// 1. `"person"`: The key "person" is associated with another Json object that contains information about
// a person.
// 2. `"friends"`: The key "friends" is associated with a Json array containing the names of friends.
/* Remember that Json is a highly structured data format, and must follow a specific syntax. Each
key-value pair is separated by commas, and the object itself is enclosed in curly braces `{}`. key chains
must be enclosed in double quotes, and the values can be strings, numbers, objects, arrays, or values
boolean (true or false) or null (null). */
}