Я пытаюсь получить определенное значение, например, $ json -> квитанция -> итого -> normalizedValue , используя
foreach ($json->data as $data) {
foreach ($data->receipt as $receipt) {
foreach($receipt->payment as $payment) {
foreach($payment->value as $value) {
foreach($value->normalizedValue as $normalizedValue) {
echo json_encode($normalizedValue) . "\n";
}
}
}
}
Однако я получаю пустой вывод , API ответил файлом xml, который я закодировал в json. Я так долго пытался это выяснить, и понятия не имею, что происходит. Может кто-нибудь помочь? Спасибо
{
"@attributes": {
"count": "1"
},
"receipt": {
"@attributes": {
"currency": "USD",
"rotation": "RT_Clockwise"
},
"vendor": {
"@attributes": {
"confidence": "0.000",
"isSuspicious": "true"
},
"name": {
"recognizedValue": {
"text": "SEATTLE"
}
},
"fullAddress": {
"text": {}
},
"address": {
"text": {}
},
"phone": {
"@attributes": {
"confidence": "70",
"isSuspicious": "true"
},
"normalizedValue": "2066219777",
"recognizedValue": {
"text": "206\n621\n9777"
}
},
"purchaseType": "GasolineStation",
"city": {
"normalizedValue": "Seattle",
"recognizedValue": {
"text": "SEATTLE"
}
},
"zip": {
"@attributes": {
"confidence": "99",
"isSuspicious": "false"
},
"normalizedValue": "98134",
"recognizedValue": {
"text": "98134"
}
},
"administrativeRegion": {
"normalizedValue": "WA",
"recognizedValue": {
"text": "WA"
}
}
},
"date": {
"@attributes": {
"confidence": "100",
"isSuspicious": "false"
},
"normalizedValue": "2020-04-02",
"recognizedValue": {
"text": "04/02/20"
}
},
"time": {
"@attributes": {
"confidence": "100",
"isSuspicious": "false"
},
"normalizedValue": "14:17:49",
"recognizedValue": {
"text": "14:17:49"
}
},
"total": {
"@attributes": {
"confidence": "34",
"isSuspicious": "true"
},
"normalizedValue": "150.00",
"recognizedValue": {
"text": "150\n00"
}
},
"tax": {
"@attributes": {
"total": "false"
},
"normalizedValue": "0.00",
"recognizedValue": {
"text": "0.00"
}
},
"payment": {
"@attributes": {
"type": "Card",
"cardType": "AmericanExpress"
},
"value": {
"normalizedValue": "150.00",
"recognizedValue": {
"text": "150\n00"
}
},
"cardNumber": {
"normalizedValue": "XXXXXXXXXXXX2467",
"recognizedValue": {
"text": "X2467"
}
}
},
"recognizedItems": {
"@attributes": {
"count": "1"
},
"item": {
"@attributes": {
"index": "1"
},
"name": {
"@attributes": {
"confidence": "0",
"isSuspicious": "true"
},
"text": "Prepay CA#11"
},
"count": {
"@attributes": {
"confidence": "19",
"isSuspicious": "true"
},
"normalizedValue": "1.000"
},
"total": {
"@attributes": {
"confidence": "85",
"isSuspicious": "false"
},
"normalizedValue": "150.00",
"recognizedValue": {
"text": "150.00"
}
},
"recognizedText": {},
"amountUnits": "unit"
}
},
"country": {
"@attributes": {
"confidence": "100",
"isSuspicious": "false"
},
"normalizedValue": "USA"
},
"recognizedText": {}
}
}