json example
{ "name": "Muhammad Ishaq", "gender": "Male", "age": 23, "address": { "street": "87", "city": "Gultari Matyal Skardu", "state": "Gilgit Baltistan", "postalCode": "16350" }, "phoneNumber": [ { "type": "personal", "number": "116263747" } ] }
Source: www.learningcontainer.com
create a json object in javascript
var employee = { "firstName": firstName, "lastName": lastName }
Source: stackoverflow.com
JSON data example
[{"_id":"60beb338abe3dd4300d844b8","email":"hemitpatel0@gmail.com","typeVaccine":"Moderna","status":"Yes","__v":0},{"_id":"60bf716b145de95f1c84fb2f","email":"hemit.2009@outlook.com","typeVaccine":"Asternzcana","status":"No","__v":0},{"_id":"60bf7196145de95f1c84fb31","email":"hemitpatel@computer4u.com","typeVaccine":"Phizer","status":"Yes","__v":0},{"_id":"60bf758f145de95f1c84fb32","email":"blahbro96@gmail.com","typeVaccine":"none","status":"No","__v":0}]
json object
var myObj, x; myObj = {"name":"John", "age":30, "car":null}; x = myObj.name; document.getElementById("demo").innerHTML = x;
JSON Example
const x = {a:"aaaaa", b: function(){return this.a}, c: function(){this.a}}; console.log(x.b()); /* const x = {a:"aaaaa", b: this.a, c: this.a}; console.log(x.b); will return undefined */
JSON Use Example
function get(value, p) { console.log(p[value]); } get("x", {x:"XXX%%$$$%$%#$%#"});