public class test {
public static void main(String[] args) {
Map<String, Double> map = new HashMap<String, Double>();
map.put("value01", 1.0);
map.put("value02", 2.0);
ObjectMapper mapper = new ObjectMapper();
String json;
try {
json = mapper.writeValueAsString(map);
System.out.println(json);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
输出: