Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!