我有这个数据。我可以将它转换为php关联数组吗?实际上我很困惑。我尝试使用 json_decode 和反序列化。在这里帮助我。提前谢谢。
"data": {
"address": "101, B Wing, Ashapura Park, Dombivli East",
"area": "thane",
"area_id": 51466,
"field_agent": {
"email": "abin@example.in",
"name": "Jacob Mattom",
"phone": 2147483647
},
"geo_location_city": "thane",
"geo_location_city_id": 2430,
"keywords": [
"sample for tesing"
],
"lat": null,
"lng": null,
"location_id": 5578,
"media": [
{
"MediaId": "0bd41ec2f0bc11e58fd5066a28c33ece",
"thumb_url": "http://example-datapipeline-staging.s3-ap-southeast-1.examplezz.com/0bd41ec2f0bc11e58fd5066a28c33ece.mp4",
},
{
"MediaId": "28c3823ef0bc11e5b825066a28c33ece",
"thumb_url": "http://example-datapipeline-staging.s3-ap-southeast-1.examplezz.com/28c3823ef0bc11e5b825066a28c33ece.mp4",
}
],
"meta": {
"Product": [
{
"brand": "",
"categorykeywords": [
"Construction Tools Indl",
"Construction Tools",
"Industrial Construction Tools",
"Tools",
""
],
"categorykeywordsexact": [
"Construction Tools Indl",
"Construction Tools",
"Industrial Construction Tools",
"Tools",
""
],
"categorypath": "Top/Construction Equipments/Construction Tools- Indl",
"description": "",
"id": 10395376,
"imageurls": "",
"intattribute": [
{
"answer": 0,
"qaggr": "",
"question": ""
},
{
"answer": 0,
"qaggr": "",
"question": ""
},
{
"answer": 0,
"qaggr": "",
"question": ""
},
{
"answer": 0,
"qaggr": "",
"question": ""
}
],
"keywords": [],
"l1category": "Building & Construction",
"l2category": "Construction Equipments",
"name": "",
"parkedkeywords": [],
"stringattribute": [
{
"aaggr": [
"New"
],
"answer": [
"New"
],
"qaggr": "Condition",
"question": "Condition"
},
{
"aaggr": [
"Customized",
"Warranty"
],
"answer": [
"Customized",
"Warranty"
],
"qaggr": "Services",
"question": "Services"
},
{
"aaggr": [
"Electric",
"Hydraulic",
"Pneumatic"
],
"answer": [
"Electric",
"Hydraulic",
"Pneumatic"
],
"qaggr": "Technology",
"question": "Technology"
},
{
"aaggr": [
"Cutting Tools",
"Hand Tools",
"Plumbing Tools",
"Power Tools"
],
"answer": [
"Cutting Tools",
"Hand Tools",
"Plumbing Tools",
"Power Tools"
],
"qaggr": "Tools",
"question": "Tools"
}
]
}
],
"keywords1": [
"sample for tesing"
],
"project": "ace"
},
"outlet_status": "Valid Data",
"outlet_type": 0,
"phones": [
{
"type": "mobile",
"value": "+9198955548554"
},
{
"type": "tollfree",
"value": ""
}
],
"pincode": "22601",
"pincode_id": 151522,
"products": null,
"progress": "field executive assigned",
"qc_agency": null,
"qc_agent": null
},
"message": null,
"status": true
}
我有这个数据。我可以将它转换为php关联数组吗?实际上我很困惑。我尝试使用 json_decode 和反序列化。在这里帮助我。提前谢谢。
答案 0 :(得分:0)
我认为最简单的解决方案是使用json_decode。
$json= '"data": {"address": "101, B Wing, Ashapura Park, Dombivli East", "area": "thane", "area_id": 51466, "field_agent": {"email": "abin@example.in", "name": "Jacob Mattom", "phone": 2147483647 }}';
$obj = json_decode($json);
echo $obj->address;
echo $obj->field_agent->email;
答案 1 :(得分:0)
您的JSON数据结构错误。因为php的json_decode无法使用它。首先解决它。为了解决这个问题,您可以使用在线json编辑器。 您的json数据有什么问题:
现在你可以使用json_decode了。
以下是JSON数据的固定版本: http://www.jsoneditoronline.org/?id=689de1b78324faaced8018a2ccda1845