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

151
Views
Intentando devolver valores con su nombre clave de una matriz JSON anidada

Estoy tratando de devolver valores con su nombre clave de una matriz JSON anidada

 resData =[ { _index: 'web', _type: 'event', _id: 'web+0+93', _score: null, _source: { 'os-name': 'Windows', 'browser-version': '90.0', 'os-version': '10', }, sort: [ '20210729T05:48:03Z' ] } ]
 resData[0]._source["os-name"=>"os-name", 'browser-version'=>'90.0', 'browser-version': '90.0'];

pero dando este error

SyntaxError: lista de parámetros de función de flecha mal formada

Rendimiento esperado:

 'os-name': 'Windows', 'browser-version': '90.0', 'os-version': '10'
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Esto puede hacerse de la siguiente manera:

 const resData =[ { _index: 'web', _type: 'event', _id: 'web+0+93', _score: null, _source: { 'os-name': 'Windows', 'browser-version': '90.0', 'os-version': '10' }, sort: [ '20210729T05:48:03Z' ] } ]; const result = Object.entries(resData[0]._source) .map(e => e[0] + ': ' + e[1]) .join('\n'); console.log(result);

about 4 years ago · Juan Pablo Isaza Report

0

 const resData = [ { _index: 'web', _type: 'event', _id: 'web+0+93', _score: null, _source: { 'os-name': 'Windows', 'browser-version': '90.0', 'os-version': '10' }, sort: [ '20210729T05:48:03Z' ] } ]; const output = Object.entries(resData[0]['_source']) .map(([key, value]) => `${key}: ${value}`) .join(',\n'); console.log(output);

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!