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 238 views
1 answer 227 views
1 answer 282 views
1 answer 252 views
1 answer 296 views
2 answers 371 views
1 answer 198 views
...