java:

a、将json串转成对象:@RequestBody

b、将对象转成json串:@ResponseBody

json与对象互转:

1、将对象与json之间完成转换:原生ObjectMapper对象实现;

2、将对象转成json串过程中,指定json中key的名称,通过@JsonProperty注解实现(@JsonIgnore

3、将对象转成json串:writeValue(w,object)

String Json = objectMapper.writeValueAsString(student1);
String Json = JSON.toJSONString(dataList, SerializerFeature.WriteMapNullValue);

4、将json串转成对象:readValue(json,T.class)

Map<String, String> map = this.objectMapper.readValue(JSON.toJSONString( handler,SerializerFeature.WriteMapNullValue), Map.class);

Student=this.objectMapper.readValue(JSON.toJSONString(map.get("Info"), SerializerFeature.WriteMapNullValue), Student.class);