Php parses json data and php parses json data
<? Php
$ Data;
$ Data. = "[";
For ($ I = 0; $ I <20; $ I ++)
{
$ Data. = "{";
$ Data. = "\" id \ ": \" ". 110 ."\",";
$ Data. = "\" name \ ": \" ". 110 ."\",";
$ Data. = "\" original_price \":\""
. 110 ."\",";
$ Data. = "\" sale_price \":\""
. 110 ."\",";
$ Data. = "\" introduce \ ": \" ". 110
."\",";
$ Data. = "\" content \ ": \" ". 110
."\",";
$ Data. = "\" nums \ ":". 110 ."";
$ Data. = "}";
If ($ I <19)
{
$ Data. = ",";
}
}
$ Data. = "]";
// The premise for parsing is that $ data is in json format
$ Array = array ();
$ De_json = json_decode ($ data, true );
// Var_dump ($ de_json );
$ Count_json = count ($ de_json );
For ($ I = 0; $ I <$ count_json; $ I ++)
{
$ Array [$ I] ["id"] = $ de_json [$ I] ['id'];
$ Array [$ I] ["name"] = $ de_json [$ I] ['name'];
$ Array [$ I] ["original_price"] = $ de_json [$ I] ['original _ price'];
$ Array [$ I] ["sale_price"] = json_encode ($ de_json [$ I] ['sale _ price']);
}
Var_dump ($ array );
?>
For json data parsing in php, please refer
PHP supports JSON parsing. You can use the json_decode function.
$ Json_string = <EOT
{
"Status": "Success ",
"Request ":{
"Method": "POST ",
"Parameters ":[
{
"Name": "email ",
"Value": "lee.li@fleety.com"
},
{
"Name": "apikey ",
"Value": "ABCDEFG123456"
}
],
"From": "192.168.30.40 ",
"Timestamp": 1343285417993
},
"Duration": 14,
"Logon_user ":{
"Guid": 108142,
"Email": "lee.li@fleety.com ",
"Device_number": "UNKNOWN ",
"Is_male": true,
"Role": "USER ",
"Account_state": "ACTIVE ",
"Logon_times": 19,
"Last_logon_time": 1343285418001,
"Last_logon_by": "EMAIL ",
"Logon_host": "192.168.30.40 ",
"Logon_token": "43O8NNVC3U8KBI5OT1N07PNZF0C28AGI ",
"Created_time": 1343193738000,
"Mobile_phone": "UNKNOWN ",
"Display_name": "lee. li ",
"Is_verified": false
}
}
EOT;
$ Json_object = json_decode ($ json_string );
Echo $ json_object-> logon_user-> guid;
Reference: cn.php.net/..de.php..remainder full text>
PHP parses Json data for help
The raw data is the code. You need to perform hash transcoding. If time is used for conversion, the QQ mailbox sent to you is only good at 10 points.