var data = `{
"employee": {
"name": "John",
"age": 30,
"salary": 5000,
"city": "New York",
"skills": ["JavaScript", "CSS", "HTML"]
}
}`;
// current data type is string 'data'
console.log(typeof data);
// convert data into JSON object
var parsedData = JSON.parse(data);
console.log(typeof parsedData);
// get value from JSON object in JavaScript
console.log(parsedData.employee.name,
parsedData.employee.age,
parsedData.employee.skills);
function getCountryByCode(code) {
return data.filter(
function(data){ return data.code == code }
);
}
var found = getCountryByCode('DZ');