我已经阅读了所有JSON_DECODE帖子,但无法弄清楚如何解析这个奇怪的代码。
这是来源:
[{
"packageInfo": [
{
"ndc3Segment": "58406-435-04",
"packageDescription": "4 SYRINGE in 1 CARTON (58406-435-04) > 1 mL in 1 SYRINGE (58406-435-01) "
}
],
"unit": "mg/mL",
"strength": "50",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "SOLUTION",
"routeName": "SUBCUTANEOUS",
"startMarketing_date": "Thu Oct 06 00:00:00 EDT 2005",
"endMarketing_date": "",
"labelerName": "Immunex Corporation",
"substanceName": "ETANERCEPT",
"ndc2Segment": "58406-435"
},
{
"packageInfo": [
{
"ndc3Segment": "58406-445-04",
"packageDescription": "4 SYRINGE in 1 CARTON (58406-445-04) > 1 mL in 1 SYRINGE (58406-445-01) "
}
],
"unit": "mg/mL",
"strength": "50",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "SOLUTION",
"routeName": "SUBCUTANEOUS",
"startMarketing_date": "Thu Nov 10 00:00:00 EST 2005",
"endMarketing_date": "",
"labelerName": "Immunex Corporation",
"substanceName": "ETANERCEPT",
"ndc2Segment": "58406-445"
},
{
"packageInfo": [
{
"ndc3Segment": "58406-425-34",
"packageDescription": "4 KIT in 1 CARTON (58406-425-34) > 1 KIT in 1 KIT (58406-425-41) * 1 mL in 1 VIAL * 1 mL in 1 SYRINGE (58406-910-01) "
}
],
"unit": "",
"strength": "",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "KIT",
"routeName": "",
"startMarketing_date": "Thu Jan 02 00:00:00 EST 2003",
"endMarketing_date": "",
"labelerName": "Immunex Corporation",
"substanceName": "",
"ndc2Segment": "58406-425"
},
{
"packageInfo": [
{
"ndc3Segment": "54868-4782-0",
"packageDescription": "4 KIT in 1 CARTON (54868-4782-0) > 1 KIT in 1 KIT * 1 mL in 1 VIAL * 1 mL in 1 SYRINGE"
}
],
"unit": "",
"strength": "",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "KIT",
"routeName": "",
"startMarketing_date": "Wed Apr 30 00:00:00 EDT 2003",
"endMarketing_date": "",
"labelerName": "Physicians Total Care, Inc.",
"substanceName": "",
"ndc2Segment": "54868-4782"
},
{
"packageInfo": [
{
"ndc3Segment": "54868-5444-0",
"packageDescription": "4 SYRINGE in 1 CARTON (54868-5444-0) > 1 mL in 1 SYRINGE"
}
],
"unit": "mg/mL",
"strength": "50",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "SOLUTION",
"routeName": "SUBCUTANEOUS",
"startMarketing_date": "Thu Oct 06 00:00:00 EDT 2005",
"endMarketing_date": "",
"labelerName": "Physicians Total Care, Inc.",
"substanceName": "ETANERCEPT",
"ndc2Segment": "54868-5444"
},
{
"packageInfo": [
{
"ndc3Segment": "58406-455-04",
"packageDescription": "4 SYRINGE in 1 CARTON (58406-455-04) > .5 mL in 1 SYRINGE (58406-455-01) "
}
],
"unit": "mg/.5mL",
"strength": "25",
"nda": "BLA103795",
"proprietaryName": "ENBREL",
"nonProprietaryName": "etanercept",
"dosageFormname": "SOLUTION",
"routeName": "SUBCUTANEOUS",
"startMarketing_date": "Thu Nov 10 00:00:00 EST 2005",
"endMarketing_date": "",
"labelerName": "Immunex Corporation",
"substanceName": "ETANERCEPT",
"ndc2Segment": "58406-455"
}]
我看到的所有嵌套JSON都有一个顶级通用数据名称,这似乎有“packageInfo”作为记录顶部,但我认为需要一个优于“packageInfo”的对象来保存它们。我一定是错的。
我如何打印每个“proprietaryName”?
答案 0 :(得分:1)
尝试
$json = json_decode($jsonstring);
foreach ($json as $package){
echo $package->proprietaryName;
}