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

138
Vistas
Create a new array from current Airtable array

How can I get this old array:

[
    {
        "_table": {
            "_base": {
                "_airtable": {},
                "_id": "appDxGpKPJl3Exjs2"
            },
            "id": null,
            "name": "PropMatters"
        },
        "id": "recGBOdnDtrvaEu7N",
        "_rawJson": {
            "id": "recGBOdnDtrvaEu7N",
            "createdTime": "2022-05-24T07:05:22.000Z",
            "fields": {
                "Name": "Mon 23 May, Tues 24 May",
                "KeyID": "2024f0d10106261cdc852194042d731c"
            }
        },
        "fields": {
            "Name": "Mon 23 May, Tues 24 May",
            "KeyID": "2024f0d10106261cdc852194042d731c"
        }
    },
    {
        "_table": {
            "_base": {
                "_airtable": {},
                "_id": "appDxGpKPJl3Exjs2"
            },
            "id": null,
            "name": "PropMatters"
        },
        "id": "recS98niJqeUmlQ1n",
        "_rawJson": {
            "id": "recS98niJqeUmlQ1n",
            "createdTime": "2022-05-24T07:59:22.000Z",
            "fields": {
                "Name": "Mediator Demo",
                "KeyID": "eb0e79a50044cf02c1969e7f20093788"
            }
        },
        "fields": {
            "Name": "Mediator Demo",
            "KeyID": "eb0e79a50044cf02c1969e7f20093788"
        }
    }
]

To output something like this:

[ 
   {
     "Name": "Mon 23 May, Tues 24 May",
     "KeyID": "2024f0d10106261cdc852194042d731c"
   },
   {
     "Name": "Mediator Demo",
     "KeyID": "eb0e79a50044cf02c1969e7f20093788"
   },
]

So as you can see, I'd like to output a new array simplifying the old JSON array to loop through each "fields" array item.

I have a feeling I'd use js maparray function, but I get lost if it's more than a simple array.

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

0

If I understand your question correctly you can easily map over given array

const arr = [
  {
    "_table": {
      "_base": {
        "_airtable": {},
        "_id": "appDxGpKPJl3Exjs2"
      },
      "id": null,
      "name": "PropMatters"
    },
    "id": "recGBOdnDtrvaEu7N",
    "_rawJson": {
      "id": "recGBOdnDtrvaEu7N",
      "createdTime": "2022-05-24T07:05:22.000Z",
      "fields": {
        "Name": "Mon 23 May, Tues 24 May",
        "KeyID": "2024f0d10106261cdc852194042d731c"
      }
    },
    "fields": {
      "Name": "Mon 23 May, Tues 24 May",
      "KeyID": "2024f0d10106261cdc852194042d731c"
    }
  },
  {
    "_table": {
      "_base": {
        "_airtable": {},
        "_id": "appDxGpKPJl3Exjs2"
      },
      "id": null,
      "name": "PropMatters"
    },
    "id": "recS98niJqeUmlQ1n",
    "_rawJson": {
      "id": "recS98niJqeUmlQ1n",
      "createdTime": "2022-05-24T07:59:22.000Z",
      "fields": {
        "Name": "Mediator Demo",
        "KeyID": "eb0e79a50044cf02c1969e7f20093788"
      }
    },
    "fields": {
      "Name": "Mediator Demo",
      "KeyID": "eb0e79a50044cf02c1969e7f20093788"
    }
  }
]

console.log(arr.map((item) => item.fields))

about 4 years ago · Juan Pablo Isaza Denunciar

0

The objects that you want in your array just correspond to the "fields" key in the "old" array. So you can just map the array:

const oldArray = JSON.parse(json);
const newArray = oldArray.map(entry => entry.fields);

And turn it back to JSON if needed.

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