在将 java 对象转换为 json 方面需要您的帮助。当前的 json 结果以小写字母显示所有键,我需要它是大写的。
ObjectMapper mapper = new ObjectMapper();
Writer strWriter = new StringWriter();
mapper.writeValue(strWriter, obj);
String jsonString= strWriter.toString();
结果是
[{"flags":"1","name":"Peter","location":"London","startDate":"2012-01-06 00:00"}]
但我想要这样的结果(所有键键值都应该大写):
[{"FLAGS":"YU","NAME":"Peter","LOCATION":"London","STARTDATE":"2012-01-06 00:00"}]
并且也有可能得到这样的(大写的关键第一个字母):
[{"Flags":"1","Name":"Peter","Location":"London","StartDate":"2012-01-06 00:00"}]
谁可以帮我这个事。
提前致谢。