add JSONEngineConfig

This commit is contained in:
Looly
2024-08-10 11:27:51 +08:00
parent 6171f51251
commit 40fbed9173
12 changed files with 301 additions and 58 deletions

View File

@@ -27,21 +27,21 @@ public class JSONStrFormatterTest {
@Test
public void formatTest() {
final String json = "{'age':23,'aihao':['pashan','movies'],'name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies','name':{'firstName':'zhang','lastName':'san','aihao':['pashan','movies']}]}}";
final String result = JSONStrFormatter.format(json);
final String result = JSONStrFormatter.INSTANCE.format(json);
Assertions.assertNotNull(result);
}
@Test
public void formatTest2() {
final String json = "{\"abc\":{\"def\":\"\\\"[ghi]\"}}";
final String result = JSONStrFormatter.format(json);
final String result = JSONStrFormatter.INSTANCE.format(json);
Assertions.assertNotNull(result);
}
@Test
public void formatTest3() {
final String json = "{\"id\":13,\"title\":\"《标题》\",\"subtitle\":\"副标题z'c'z'xv'c'xv\",\"user_id\":6,\"type\":0}";
final String result = JSONStrFormatter.format(json);
final String result = JSONStrFormatter.INSTANCE.format(json);
Assertions.assertNotNull(result);
}
@@ -49,6 +49,6 @@ public class JSONStrFormatterTest {
@Disabled
public void formatTest4(){
final String jsonStr = "{\"employees\":[{\"firstName\":\"Bill\",\"lastName\":\"Gates\"},{\"firstName\":\"George\",\"lastName\":\"Bush\"},{\"firstName\":\"Thomas\",\"lastName\":\"Carter\"}]}";
Console.log(JSONUtil.formatJsonStr(jsonStr));
Console.log(JSONStrFormatter.INSTANCE.format(jsonStr));
}
}

View File

@@ -79,7 +79,7 @@ public class JSONEngineFactoryTest {
@Test
void fastJSON2Test() {
final JSONEngine engine = JSONEngineFactory.createEngine("fastjson2");
final JSONEngine engine = JSONEngineFactory.createEngine("fastjson");
assertEquals(FastJSON2Engine.class, engine.getClass());
final StringWriter stringWriter = new StringWriter();