Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda