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

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

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 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