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

141
Visualizações
removing a json array object item if it matches a string

In my index file, I am accessing this json using fs. I am trying to remove one of the array object items where a string input in my external index.js file matches the value of the "ChannelName" key.

I have tried finding the index of the item where the channelname matches the string input but this didn't work(Converted to an array to try this).

Has anyone any ideas? Is this even possible?

{
    "DiscordServerId":"",
    "token":"",
    "twitch_clientID":"",
    "twitch_secret":"",
    "cron":"*/10 * * * *",
    "channelID":"",
    "roleID":"everyone",
    "channels":[
        {
            "ChannelName":"channel1",
            "DiscordServer":"",
            "twitch_stream_id":"",
            "discord_nessage_id":""},
        {
            "ChannelName":"channel2",
            "DiscordServer":"",
            "twitch_stream_id":"",
            "discord_nessage_id":""
        },
        {
            "ChannelName":"channel2",
            "DiscordServer":"",
            "twitch_stream_id":"",
            "discord_nessage_id":""
        }
    ],
    "authToken":""}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can update the channels with some condition.

const searchChannelName = "channel2";
const data = {
  "DiscordServerId": "",
  "token": "",
  "twitch_clientID": "",
  "twitch_secret": "",
  "cron": "*/10 * * * *",
  "channelID": "",
  "roleID": "everyone",
  "channels": [
    {
      "ChannelName": "channel1",
      "DiscordServer": "",
      "twitch_stream_id": "",
      "discord_nessage_id": ""
    },
    {
      "ChannelName": "channel2",
      "DiscordServer": "",
      "twitch_stream_id": "",
      "discord_nessage_id": ""
    },
    {
      "ChannelName": "channel2",
      "DiscordServer": "",
      "twitch_stream_id": "",
      "discord_nessage_id": ""
    }
  ],
  "authToken": ""
}
data.channels = data.channels.filter((node => node.ChannelName !== searchChannelName));
console.log(data);

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