How to convert js objects into arrays in php?

  1. write a crawler with GuzzleHttp of laravel , grab the data of .net interface, and return it as jsonp
  2. the string with the function removed is as follows
[{ gid:"10000",gname:"",gspell:"yiqiaodi",child:[{"id":"3999","name":"A3","urlSpell":"aodia3-3999","showName":"A3","saleState":""}]}]
  1. how do I turn this string into an array of php ?
Jul.18,2022

[{gid: "10000", gname: "FAW Audi", gspell: "yiqiaodi", child: [{"id": "3999", "name": "A3", "urlSpell": "aodia3-3999", "showName": "Audi A3", "saleState": "in sale"]}] this is not a php standard json string, and the key value has no quotation marks.

$data ='[{"gid": "10000", "gname": "FAW Audi", "gspell": "yiqiaodi", "child": [{"id": "3999", "name": "A3", "urlSpell": "aodia3-3999", "showName": "Audi A3", "saleState": "in sale"}]}]';
$result = json_decode ($data,true);
var_dump ($result);


$str = preg_replace(["/([a-zA-Z_]+[a-zA-Z0-9_]*)\s*:/", "/:\s*'(.*?)'/"], ['"\1":', ': "\1"'], $str);
var_dump(json_decode($str,true));

$str = <<<STR
[{ gid:"10000",gname:"",gspell:"yiqiaodi",child:[{"id":"3999","name":"A3","urlSpell":"aodia3-3999","showName":"A3","saleState":""}]}]
STR;
echo preg_replace('/([\w]+:)/','"$1":',$str);

output

json_decode($data,true);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be0b7a-398da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be0b7a-398da.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?