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

464
Views
¿Cómo eliminar el corchete cuadrado de JSON en JavaScript o en php?

Tengo algunos datos JSON, se están emparejando así ahora

 [ [ { 'key': 'value' }, { 'key': 'value' } ] ]

Lo que quiero hacer es quitar el segundo corchete de aquí así:

 [ { 'key': 'value' }, { 'key': 'value' } ]

He aplicado algunos algoritmos tanto en PHP como en javascript pero no funciona por favor ayudame si sabes como solucionar esto

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar el método PHP array_merge() como este (PHP 7.4 o superior)

EDITAR: decodifique la cadena JSON usando la función php json_decode () antes.

 $flattened_array = array_merge(...$arr);

https://wiki.php.net/rfc/spread_operator_for_array

https://www.php.net/manual/pt_BR/function.array-merge.php

O simplemente haz esto:

 $arr = "[ [ { 'key': 'value' }, { 'key': 'value' } ] ]" //receives a JSON string; $flattened_arr = json_decode($arr[0]) //decodes it;
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!