I have a json encoded associative array which contains a combination of map and list this is done in PHP.
This json string is transferred to java via web service call
How do I handle this json string to get the original associative array data. I know java doesn't support associative array. But any alternatives are appreciated.
Sample json string:
{
"seminar_info":{
"seminar_id":"3485",
"seminar_name":"Importance of breast-feeding Seminar",
"start_date":"10\/20\/2015",
"end_date":"10\/22\/2015",
"venue":"Watefront Hotel",
"schedules":{
"2531":{
"date-title":"12\/20 Introduction to breastfeeding",
"classes":{
"4857":{
"detail":"10:00-12:00 Importance of breast feeding",
"points":"16"
},
"4858":{
"detail":"13:00-15:00 Myths of formula solutions",
"points":"10"
},
"4859":{
"detail":"16:00-18:00 What we should know about Breast feeding",
"points":"10"
}
},
"meals":{
"4756":"Happy meal set",
"4757":"Healthy all veggie meal set",
"4758":"All pork set"
}
},
"2532":{
"date-title":"12\/21 Breastfeeding long term impacts to mother and child",
"classes":{
"4860":{
"detail":"10:00-12:00 The healthy parent pt1",
"points":"12"
},
"4861":{
"detail":"13:00-15:00 The healthy parent pt2",
"points":"9"
}
},
"meals":{
"4756":"Happy meal set",
"4757":"Healthy all veggie meal set",
"4758":"All pork set"
}
}
},
"books":{
"9671":{
"book_name":"Ideas for Dr. Kitamura",
"description":"Everything about life and breast feeding"
}
},
"products":{
"9672":{
"product_name":"lanex tshirt",
"description":"tshirt of lanex"
}
}
},
"participants":{
"2130":{
"name":"Galapate, Raymund",
"emailad":"chuvaness@gmail.com",
"lecturer_flag":"true",
"sequence_num":"1",
"seminar_info":{
"schedules_checked":{
"2531":{
"classes":["4857","4858","4859"],
"children_info":{
"age_three":"1",
"age_others":"2",
"children_accompany_val":"Available",
"separate_child_val":"Nothing",
"parent_child_room_val":"Yes",
"parent_child_space_val":"Yes",
"child_info":"Child1, Child2, Child3",
"attendant":"accompany1",
"note":"Child1 is abnormal"
},
"meals":["4756","4757"]
},"2532":{
"classes":["4857"],
"meals":["4756"]
}
},
"books":{
"9671":"1"
},
"products":{
"9672":"2"
}
}
},
"2131":{
"name":"Caruana, AC",
"emailad":"acgurl@gmail.com",
"lecturer_flag":"false",
"sequence_num":"2",
"seminar_info":{
"schedules_checked":{
"2531":{
"classes":["4857","4858","4859"],
"meals":["4756","4757"]
}
}
}
}
}
}
Use javax.jason
try (JsonReader jsonReader = Json.createReader(new StringReader(jsonString))) {
JsonObject object = jsonReader.readObject();
System.out.println(object);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.