Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
Making a search in json file by query

i want to make a search in a json file by query Example: My json file:

[{
"Id":1,
"name":"test"
},
{
"Id":2,
"name":"test"
}]

And if i search {"name":"test"} i get the full objects whos name is test

ADD: I misspoke its the user who enter the query how can i get the key and the value from the query {key:value} and the user can entre multiple keys and values (like the search in atlas mongodb) UP!!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

As per your question you are using JSON inside of an array. So you can simply filter the array to find JSON which contains name="test"

Follow the below step:

let userArray = [{"Id":1,"name":"test"},{"Id":2,"name":"test"}]

const filteredUser = userArray.filter((user) => user.name === "test")
about 4 years ago · Juan Pablo Isaza Report

0

Try something simple:

var myjson ='[{"Id":1,"name":"test"},{"Id":2,"name":"test"},{"Id":3,"name":"nottest"}]';
var slag = JSON.parse(myjson).filter(doc => doc.name === 'test');
console.log(slag);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!