|
| 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