com.fasterxml.jackson完成json转map

com.fasterxml.jackson完成json转map

在开发时有时候需要将接收到的json字符串转成map
<dependency>
    <groupId>com.fasterxml.jackson.coregroupId>
    <artifactId>jackson-databindartifactId>
dependency>
try{
     String jsonStr = "{\"errcode\":40163,\"errmsg\":\"code been used, hints: [ req_id: .bYjNa04342034 ]\"}";   
     ObjectMapper objectMapper = new ObjectMapper();
     HashMap<String,Object> map = objectMapper.readValue(jsonStr,HashMap.class);
}catch(Exception e){
    e.printStackTrace();
}

你可能感兴趣的:(com.fasterxml.jackson完成json转map)