How can I convert JSON string to HashMap. My JSON string is like
{
"AvailableDeliveries": {
"500": {
"code": "INOFFICE",
"desc": "In Office",
"id": 500,
"name": "IN OFFICE"
},
"502": {
"code": "TELEPHONE",
"desc": "Telephone",
"id": 502,
"name": "TELEPHONE"
},
"503": {
"code": "DIY DOC ACCESS",
"desc": "Online Documents",
"id": 503,
"name": "DIY DOC ACCESS"
}
}
}
I looked on other examples which have collection of object but I have this extra top level object "AvailableDeliveries" not sure how to handle that level.
import jackson-all-1.8.2.jar create a mapper for the object mapper
ObjectMapper objectMapper = new ObjectMapper();
create a hashmap
map = objectMapper.readValue( json, HashMap.class );
Hope this will work
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.