what is a json object code example
Example 1: what is JSON
JavaScript Object Notation
Its a key value pair
its popular light-weight way of transfering data
for example :
Lets try to create a json for Person Object
with name , age , isMarried , gender
Its ket value pair
the key is always String and need to be in quotation
value can be :
String
Number
Boolean
null
array
another json object
This is one json with 5 fields
each key value pair should be separated by comma
{
"name" : "Anna",
"age" : 18 ,
"isMarried" : false ,
"gender" : "female",
"company" : null
}
Example 2: json deep dot
Prototype code is available here
https://gist.github.com/Cirilord/d0d3f0ba7171deed26bfffe4787d6e0b
Example
let y = {}
Object.deep.(y, 'x.y.z')
console.log(y)
OR
let x = {}
Object.deep.(x, 'x.y.z', 10)
console.log(x)
Example 3: json object
var myObj, x;
myObj = {"name":"John", "age":30, "car":null};
x = myObj.name;
document.getElementById("demo").innerHTML = x;
Example 4: json objects
{ "name":"John", "age":30, "car":null }