我对 pointX 和 pointY 使用@JSONField 注释,我想将 pointX 更改为 point_x!我想像point_x一样显示pointX!但它没有用!它始终是 pointX 和 pointY!但其他领域还可以!
我的java bean是这样的!
@Data
public class PointListOutput {
@JSONField(name = "latest_area_point_list")
private List<Point> latestAreaPointList;
@Data
public static class Point {
@JSONField(name = "point_x")
private Float pointX;
@JSONField(name = "point_y")
private Float pointY;
}
}
我的配置
@Override
protected void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
// create FastJson converter
final FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
final List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
converter.setSupportedMediaTypes(supportedMediaTypes);
// create configuration class
final FastJsonConfig config = new FastJsonConfig();
// update filter of response
config.setSerializerFeatures(SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue);
converter.setFastJsonConfig(config);
converters.add(new ByteArrayHttpMessageConverter());
converters.add(converter);
}
这是我的 http 响应,您可以看到 pointX 是 pointX!不是point_x!
{
"code": 1,
"message": "Success",
"data": [
{
"latest_area_point_list": [
{
"pointX": 1.1,
"pointY": 1.1
},
{
"pointX": null,
"pointY": 1.1
}
]
}
]
}