Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get Value From JSON Object In JavaScript

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);
Source by www.tutorialstonight.com #
 
PREVIOUS NEXT
Tagged: #Get #Value #From #JSON #Object #In #JavaScript
ADD COMMENT
Topic
Name
2+9 =