mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
fix code
This commit is contained in:
@@ -225,7 +225,9 @@ public interface JSON extends Serializable {
|
||||
* @throws JSONException 包含非法数抛出此异常
|
||||
*/
|
||||
default String toJSONString(final int indentFactor) throws JSONException {
|
||||
return toJSONString(indentFactor, null);
|
||||
final JSONWriter jsonWriter = getFactory().ofWriter(new StringBuilder(), indentFactor);
|
||||
this.write(jsonWriter);
|
||||
return jsonWriter.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,12 +38,6 @@ public class JsonToStringJmh {
|
||||
Assertions.assertNotNull(jsonStr);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void gsonAppendJmh() {
|
||||
final String jsonStr = gson.toString();
|
||||
Assertions.assertNotNull(jsonStr);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void hutoolJmh() {
|
||||
final String jsonStr = hutoolJSON.toString();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.dromara.hutool.json.jmh;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.dromara.hutool.json.JSONObject;
|
||||
@@ -49,4 +52,11 @@ public class ParseTreeJmh {
|
||||
final com.alibaba.fastjson2.JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
assertNotNull(jsonObject);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public void jacksonJmh() throws JsonProcessingException {
|
||||
final ObjectMapper mapper = new ObjectMapper();
|
||||
final JsonNode jsonNode = mapper.readTree(jsonStr);
|
||||
assertNotNull(jsonNode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user