mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix json format bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -8,7 +9,7 @@ import org.junit.Test;
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public class JSONStrFormaterTest {
|
||||
public class JSONStrFormatterTest {
|
||||
|
||||
@Test
|
||||
public void formatTest() {
|
||||
@@ -16,18 +17,24 @@ public class JSONStrFormaterTest {
|
||||
String result = JSONStrFormatter.format(json);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void formatTest2() {
|
||||
String json = "{\"abc\":{\"def\":\"\\\"[ghi]\"}}";
|
||||
String result = JSONStrFormatter.format(json);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void formatTest3() {
|
||||
String json = "{\"id\":13,\"title\":\"《标题》\",\"subtitle\":\"副标题z'c'z'xv'c'xv\",\"user_id\":6,\"type\":0}";
|
||||
String result = JSONStrFormatter.format(json);
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatTest4(){
|
||||
String jsonStr = "{\"employees\":[{\"firstName\":\"Bill\",\"lastName\":\"Gates\"},{\"firstName\":\"George\",\"lastName\":\"Bush\"},{\"firstName\":\"Thomas\",\"lastName\":\"Carter\"}]}";
|
||||
Console.log(JSONUtil.formatJsonStr(jsonStr));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user