I am new in unity and I need to download data from JSON. I successfully download JSON data but I am not able to parse the JSON. I have use Boomlagoon Asset to serialize my JSON. Here is my code.
void Start() {
string url = "http://www.windmillinfotech.com/carlife/carlife_api/get_workshop";
WWWForm form = new WWWForm();
form.AddField("district", "Dhaka");
form.AddField("thana", "Mirpur");
form.AddField("service_type", "car");
WWW www = new WWW( url, form );
StartCoroutine (request(www));
}
IEnumerator request (WWW www) {
yield return www;
if(!string.IsNullOrEmpty(www.error)) {
print( "Error : " + www.error );
} else {
string serviceData = www.text;
JSONObject json = JSONObject.Parse(serviceData);
print ("\n\n\n\n"+json["workshop_dtls_result"]);
}
}
and my JSON result is like follows,
{
"success": true,
"workshop_dtls_result": [
{
"id": "141",
"user_id": "",
"store_id": null,
"updated_by": null,
"workshop_name": "Okay Auto Engineering",
"workshop_email": "",
"workshop_address": "Section -10, Block - A, Plot - 9, Main Road, Mirpur, Dhaka-1216. Behind the graveyard, 01712978222",
"district": "Dhaka",
"thana": "Mirpur",
"post_code": "",
"contact_person": "Sabir Hossain",
"contact_number": "01712978222",
"alternative_number": "",
"service_type_car": "Car",
"service_type_bus": "",
"service_type_bike": "",
"workshop_photo_1": "",
"workshop_photo_2": "",
"workshop_photo_3": "",
"latitude": "",
"longitude": "",
"create_date": "2017-01-01",
"active_status": "Active",
"workshop_services": null,
"lubricants_available": "No",
"lubricant_products": null
},
{
"id": "142",
"user_id": "",
"store_id": null,
"updated_by": null,
"workshop_name": "Ali Automobile ",
"workshop_email": "",
"workshop_address": "Section -11, Block- D, Avenue-1 Plot-14, Mob: 01925920115",
"district": "Dhaka",
"thana": "Mirpur",
"post_code": "",
"contact_person": "Mohammad Ali",
"contact_number": "01925920115",
"alternative_number": "",
"service_type_car": "Car",
"service_type_bus": "",
"service_type_bike": "",
"workshop_photo_1": "",
"workshop_photo_2": "",
"workshop_photo_3": "",
"latitude": "",
"longitude": "",
"create_date": "2017-01-01",
"active_status": "Active",
"workshop_services": null,
"lubricants_available": "No",
"lubricant_products": null
}
]
}
Now my question is that how can I get each values of id, workshop_name etc? Please help me to parse this JSON data. Thanks in advance.