Skip to content

Commit b80ac43

Browse files
committed
feature(json): 添加测试代码
1. 添加测试代码
1 parent 82081bf commit b80ac43

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

json-diff-test/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,10 @@
5050
<artifactId>slf4j-log4j12</artifactId>
5151
<version>2.0.0-beta1</version>
5252
</dependency>
53+
<dependency>
54+
<groupId>cn.hutool</groupId>
55+
<artifactId>hutool-all</artifactId>
56+
<version>5.7.5</version>
57+
</dependency>
5358
</dependencies>
5459
</project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package me.codeleep.jsondiff.test.bigdata;
2+
3+
4+
import cn.hutool.core.io.file.FileReader;
5+
import com.alibaba.fastjson2.JSON;
6+
import me.codeleep.jsondiff.common.model.JsonCompareResult;
7+
import me.codeleep.jsondiff.common.model.JsonComparedOption;
8+
import me.codeleep.jsondiff.core.DefaultJsonDifference;
9+
import me.codeleep.jsondiff.core.config.JsonDiffOption;
10+
import me.codeleep.jsondiff.core.utils.JsonNeatFactory;
11+
import java.io.FileNotFoundException;
12+
import java.util.Scanner;
13+
14+
15+
/**
16+
* @author: codeleep
17+
* @createTime: 2022/11/22 16:57
18+
* @description:
19+
*/
20+
public class BigJsonTest {
21+
22+
public static void main(String[] args) throws FileNotFoundException {
23+
Scanner scanner = new Scanner(System.in);
24+
while (scanner.nextInt() == 0) {
25+
test();
26+
}
27+
}
28+
29+
30+
public static void test() throws FileNotFoundException {
31+
FileReader expectFile = new FileReader("classpath:bigdata/expect.json");
32+
FileReader actualFile = new FileReader("classpath:bigdata/actual.json");
33+
String expectJson = expectFile.readString();
34+
String actualJson = actualFile.readString();
35+
JsonNeatFactory jsonNeatFactory = JsonDiffOption.getJsonNeatFactory();
36+
37+
JsonComparedOption jsonComparedOption = new JsonComparedOption().setIgnoreOrder(true);
38+
JsonCompareResult jsonCompareResult = new DefaultJsonDifference()
39+
.option(jsonComparedOption)
40+
.detectDiff(JSON.parseObject(expectJson), JSON.parseObject(actualJson));
41+
System.out.println(JSON.toJSONString(jsonCompareResult));
42+
43+
}
44+
}

0 commit comments

Comments
 (0)