public final class JSONUtil{
public static <T> T readValue(String content, Class<T> valueType) {
if (content == null) {
return null;
}
T result = null;
ObjectMapper objectMapper = new ObjectMapper();
try {
result = objectMapper.readValue(content, valueType);
} catch (IOException e) {
throw new RuntimeException("write json error", e);
}
return result;
}
public static void main(String[] args) {
//造点数据,10万条json
List<String> list = new ArrayList<>();
for (int i = 0; i < 100000; i++) {
list.add("{\"mame\":\"wwq1\",\"age\":"+i+"}");
}
//避免jvm预热影响,这里使用线程池测试
ExecutorService executorService = Executors.newFixedThreadPool(10
java各种List循环:性能效率对比
最新推荐文章于 2024-07-11 20:05:52 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)