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

176
Views
Id. y nombre separados en clave de JSON

Tengo datos sobre el trabajador en mi base de datos en formato JSON. que se parece a esto

 {"45051-Cortador 1 Siloc": "hsgvs", "45063-Nihil impedit quia": "okbbd",}

en esta clave JSON contiene la identificación y el nombre del usuario, por ejemplo, en la primera clave 45051 es la identificación y Cortador 1 Siloc es el nombre del usuario. Quiero la identificación de la clave para poder usarla y quiero usarla en Laravel Controller (PHP). Gracias,

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puedes usar dividir aquí

 const obj = { "45051-Cortador 1 Siloc": "hsgvs", "45063-Nihil impedit quia": "okbbd", }; const result = Object.keys(obj).map((s) => s.split("-")); console.log(result); result.forEach(([k, v]) => console.log(k, v));
 /* This is not a part of answer. It is just to give the output fill height. So IGNORE IT */ .as-console-wrapper { max-height: 100% !important; top: 0; }

over 4 years ago · Santiago Trujillo Report

0

Puedes usar la colección

 $result= collect(json_decode($json))->map(function ($item,$key){ $data=explode("-",$key); return ['id'=>$data[0]??null,'name'=>$data[1]??null]; })->values()
over 4 years ago · Santiago Trujillo 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!