How to convert JSON to object in JavaScript

1 Answer

0 votes
const json = '{"id":383912,"name":"Albus Dumbledore","academicrank":"Professor"}';

const obj = JSON.parse(json);

console.log(obj);


  
  
/*
run:
  
{
  academicrank: "Professor",
  id: 383912,
  name: "Albus Dumbledore"
}
  
*/

 



answered May 24, 2022 by avibootz

Related questions

1 answer 157 views
1 answer 153 views
1 answer 182 views
1 answer 179 views
1 answer 206 views
2 answers 244 views
1 answer 115 views
...