ObjectMapper mapper = new ObjectMapper();
Map<String,String> result = mapper.readValue(src, new TypeReference<Map<String,String>>() { });
可以将json字符串转换为map对象。
本文介绍了一个使用Java的ObjectMapper将JSON字符串转换为Map对象的方法。通过创建ObjectMapper实例并调用readValue方法,可以轻松实现JSON到Map的转换。
ObjectMapper mapper = new ObjectMapper();
Map<String,String> result = mapper.readValue(src, new TypeReference<Map<String,String>>() { });
可以将json字符串转换为map对象。
转载于:https://my.oschina.net/OriginLeon/blog/678921

被折叠的 条评论
为什么被折叠?