Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda