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

188
Vistas
filter json array based on multiple arguments including lists

So I am trying to filter a json array with these two lists. what I want is if any of the element from these lists are in json array I want them in the output. this is my json array.

[{
        "sector_code": "0828", "listed_in": ["ALLSHR,KMIALLSHR" ],
    },
    {
        "sector_code": "0828","listed_in": [ "KMI30"],
    },
    {
        
        "sector_code": "0824","listed_in": ["KSE100,ALLSHR,KMIALLSHR"],
    },
    {
        "sector_code": "0833","listed_in": [ "KSE100", 'KMIALLSHR', 'LST30'],
    }]

And I have two arrays one is

listed_inilter = ['KSE100', 'KMIALLSHR']
sector_code = ['0833', '0824']

What I want is output the data from the json array even if any of the value from each list is matching.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try this on. Study about method filter in javascript to know what the code below does.

  const array = [{ sector_code: ..., listed_in: ... }]; // your array
  const listed_inilter = ['KSE100', 'KMIALLSHR'];
  const sector_code = ['0833', '0824'];

  function array_subset() {
     return array.filter(element => {
       const is_listed = listed_inilter.some(item => element.listed_in.includes(item));

       const is_sector = sector_code.includes(element.sector_code);

       return (is_listed || is_sector)
  });
}

console.log(array_subset()); // output the filtered list
    
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