我收到了以下JSON格式。我想在PHP中解码它。但我无法找到如何以下列格式获取DATA键中的数据。
JSON:
firedAt => Thu, 05 Feb 2015 20:00:13 GMT
event => orderPaid
data => [
{
"id": 10263410,
"total": 219.00,
"shipping": 0.00,
"status": {
"id": 2578171,
"title": "Betalning mottagen",
"color": "#c0ffc0",
"is_paid": true,
"is_delivered": false,
"is_active": true
},
"note": null,
"order_id": 10187,
"deleted": false,
"updated": null,
"created": "2015-02-05 21:33:18",
"reminder_sent": false,
"market": 10,
"market_reference": "47335091",
"new": true,
"integration": 274029,
"weight": "0",
"deliver_date": null,
"rows": [
{
"id": 9086694,
"quantity": 1,
"title": "Mobilskal 62613-BRU",
"reference": "62613-BRU",
"price": 219,
"market_reference": "26971426",
"tax": "25",
"created": "2015-02-05 21:33:18",
"product_id": null,
"integration": 274021,
"vat": 43.8
}
],
"customer": {
"contact": {
"id": 934714,
"alias": "Jane Doe",
"email": "jane@doe.com",
"phone": "0812839183",
"mobile": "0721231234"
},
"address": {
"id": 934714,
"first_name": "Jane",
"last_name": "Doe Svensson",
"address": "Kungsgatan 6",
"address2": "",
"zip": "37450",
"city": "Asarum",
"country": {
"name": "Sverige",
"code": "se"
}
},
"invoice": {
"id": 934714,
"first_name": "Jane",
"last_name": "Doe Svensson",
"address": "Kungsgatan 6",
"address2": "",
"zip": "37450",
"city": "Asarum",
"country": {
"name": "Sverige",
"code": "se"
}
}
},
"history": [
{
"id": "4457827",
"created": "2015-02-05 21:33:18",
"message": "Ny orderrad: 1 st Mobilskal 62613-BRU"
}
],
"icon": [
]
}
]
答案 0 :(得分:0)
json_decode($JSON['data'], true);
OR
$array = json_decode('{
"id": 10263410,
"total": 219.00,
"shipping": 0.00,
"status": {
"id": 2578171,
"title": "Betalning mottagen",
"color": "#c0ffc0",
"is_paid": true,
"is_delivered": false,
"is_active": true
},
"note": null,
"order_id": 10187,
"deleted": false,
"updated": null,
"created": "2015-02-05 21:33:18",
"reminder_sent": false,
"market": 10,
"market_reference": "47335091",
"new": true,
"integration": 274029,
"weight": "0",
"deliver_date": null,
"rows": [
{
"id": 9086694,
"quantity": 1,
"title": "Mobilskal 62613-BRU",
"reference": "62613-BRU",
"price": 219,
"market_reference": "26971426",
"tax": "25",
"created": "2015-02-05 21:33:18",
"product_id": null,
"integration": 274021,
"vat": 43.8
}
],
"customer": {
"contact": {
"id": 934714,
"alias": "Jane Doe",
"email": "jane@doe.com",
"phone": "0812839183",
"mobile": "0721231234"
},
"address": {
"id": 934714,
"first_name": "Jane",
"last_name": "Doe Svensson",
"address": "Kungsgatan 6",
"address2": "",
"zip": "37450",
"city": "Asarum",
"country": {
"name": "Sverige",
"code": "se"
}
},
"invoice": {
"id": 934714,
"first_name": "Jane",
"last_name": "Doe Svensson",
"address": "Kungsgatan 6",
"address2": "",
"zip": "37450",
"city": "Asarum",
"country": {
"name": "Sverige",
"code": "se"
}
}
},
"history": [
{
"id": "4457827",
"created": "2015-02-05 21:33:18",
"message": "Ny orderrad: 1 st Mobilskal 62613-BRU"
}
],
"icon": [
]
}', true);