Skip to content
Advertisement

How to get particular data values from JSON Node.js?

This is my JSON file output:

JavaScript

How I get id, name and email from that like below:

JavaScript

Advertisement

Answer

If your array has only one element you can just access the info, no need to build another array like this: employees[0].id , employees[0].name, employees[0].email or you can just extract an object using Object Destructuring

JavaScript

but if your array has more employees, i think what you need to do is search by id or name and get back just an object with minimal info, you can do that like this

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement