JSON数据
{
"data":{
"count":1,
"orders":[
{
"voucher_platform":0,
"voucher":0.00,
"order_number":270269205514864,
"voucher_seller":0,
"created_at":"2019-12-15 18:03:44 +0800",
"gift_option":false,
"statuses":[
"delivered"
],
"address_billing":{
"last_name":"",
"address5":"Sample",
"address4":"Sample",
"first_name":"Sample name"
},
"extra_attributes":"",
"order_id":270269205514864,
"gift_message":"",
"remarks":"",
"address_shipping":{
"country":"",
"address3":"",
"address2":"",
"city":"",
"phone":"",
}
}
]
},
"code":"0",
"request_id":"0b0da12615764049458554660"
}
我的值有问题order_number,而不是得到正确的值,270269205514864我得到的结果是2.7087557899228E+14。
我认为这个问题有点与字符串和数值有关,但我不知道如何解决它。
这是我的一些与解码 json 数据相关的代码。
...
$data = ... //assuming the json is already initialized
$data = json_decode($data, true); //decode the json
$OrderNumber = $data['data']['orders'][0]["order_number"]; //get order number
$CustomerName = $data['data']['orders'][0]["address_billing"]["first_name"]; //get name
echo $OrderNumber;
echo '<br/>';
echo $CustomerName;
echo '<br/>';
echo 'JSON DATA:';
die($data);
无论如何,JSON 来自另一台服务器,所以我无法编辑它们。我只收到 JSON。
有只小跳蛙
www说