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

158
Views
Recuperar datos de una matriz de objetos en Google Script

Estoy tratando de extraer ciertos elementos de la siguiente matriz de objetos llamada atstudentsarray y crear una nueva matriz con objetos. He usado la función de mapa a continuación, pero no puedo hacer que funcione.

 var newAtStudentArray = atstudentsarray.map(i => { const newAtStudentObj = {} newAtStudentObj.last_name = i['records'].fields['Last Name'] })

A continuación se muestra una matriz llamada atstudentsarray

 [{ "records": [ { "id": "rec02fiiNA", "createdTime": "2020-04-21T05:06:07.000Z", "fields": { "Last Name": "Lat", "Gender": "Male", "E-mail Address": "alath@bbc.lk", "Grade": "DP 2", "parent_id_2": [ "rec3TCndXH" ] } { "id": "rec02fiiNA", "createdTime": "2020-04-21T05:06:07.000Z", "fields": { "Last Name": "Lat", "Gender": "Male", "E-mail Address": "alath@bbc.lk", "Grade": "DP 2", "parent_id_2": [ "rec3TCndXH" ] } ] }]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Debe usar "retorno" si usa corchetes "{}" en su función de flecha. Agregue "return newAtStudentObj;" al final:

 var newAtStudentArray = atstudentsarray.map(i => { const newAtStudentObj = {} newAtStudentObj.last_name = i['records'].fields['Last Name'] return newAtStudentObj; })
about 4 years ago · Juan Pablo Isaza Report

0

Puedes probarlo así:

 var newAtStudentArray = atstudentsarray[0].records.map(i => ({ last_name: i.fields['Last Name'] }))

La razón por la que no funcionó para usted es porque atstudentsarray no es la matriz en la que debería estar haciendo el mapa, sino en la matriz de registros.

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!