Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

javascript find json value

function getCountryByCode(code) {
  return data.filter(
      function(data){ return data.code == code }
  );
}

var found = getCountryByCode('DZ');
Comment

PREVIOUS NEXT
Code Example
Javascript :: uncaught typeerror is not a function javascript 
Javascript :: loop elements in javascript 
Javascript :: redirect all request http to https express js 
Javascript :: binary gap 
Javascript :: get id from queryselector 
Javascript :: javascript Using debugger 
Javascript :: function range() as range js 
Javascript :: bootstrap datepicker mindate today 
Javascript :: javascript iterate object attribute name 
Javascript :: virtual dom explained 
Javascript :: javascript close window on button click 
Javascript :: useparams example 
Javascript :: javascript format date time 
Javascript :: jquery div show 
Javascript :: js split array into smaller arrays 
Javascript :: genius lyrics api 
Javascript :: js string slicing 
Javascript :: determine text truncate javascript 
Javascript :: js Write a function that will return a random integer between 10 and 100 
Javascript :: date range filter 
Javascript :: active js 
Javascript :: xmlhttprequest 
Javascript :: uploading file with fetch in js 
Javascript :: how to ssh into gke node 
Javascript :: object destructuring javascript 
Javascript :: Random Integer 1-10 
Javascript :: javascript regex example match 
Javascript :: get index of element in array js 
Javascript :: jquery sibling 
Javascript :: javascript write to text file 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =