
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Filter JSON Data with Multiple Objects
To filter JSON data with multiple objects, you can use the concept of filter along with ==.
Example
const jsonObject= [ { studentId:101, studentName:"David" }, { studentId:102, studentName:"Mike" }, { studentId:103, studentName:"David" }, { studentId:104, studentName:"Bob" } ] var result=jsonObject.filter(obj=> obj.studentName == "David"); console.log(result);
To run the above program, you need to use the following command −
node fileName.js.
Output
Here, my file name is demo194.js. This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo194.js [ { studentId: 101, studentName: 'David' }, { studentId: 103, studentName: 'David' } ]
Advertisements