
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How can I 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' } ]
- Related Questions & Answers
- How we can convert Python objects into JSON objects?
- How can I preserve Python tuples with JSON?
- How can I filter string value with starting letter?
- How can we merge two JSON objects in Java?
- How can we filter data with the help of MySQL subquery?
- How can I store JavaScript objects in cookies?
- How can I serialize python objects to XML?
- How can I make my custom objects Parcelable?
- How can I make my custom objects Serializable?
- How can I update child objects in MongoDB?
- Filter JavaScript array of objects with another array
- How can I select an element with multiple classes in jQuery?
- How can we write JSON objects to a file in Java?
- How I can create Python class from JSON object?
- How can I represent python tuple in JSON format?
Advertisements