Skip to content

Commit 07c7b02

Browse files
authored
Merge pull request #2 from codeleep/dev_4.x
feature(frame): Code finishing
2 parents 7798d3d + 64834d2 commit 07c7b02

File tree

12 files changed

+28
-101
lines changed

12 files changed

+28
-101
lines changed

Readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<div style="text-align: center">
33

44

5-
[![GitHub license](https://img.shields.io/github/license/codeleep/jsonDiff)](https://github.com/codeleep/jsonDiff/blob/master/LICENSE)
5+
[![GitHub license](https://img.shields.io/github/license/codeleep/json-diff)](https://github.com/codeleep/json-diff/blob/master/LICENSE)
66
[![star](https://gitee.com/codeleep/json-diff/badge/star.svg?theme=white)](https://gitee.com/codeleep/json-diff/stargazers)
77
<a href='https://gitee.com/codeleep/json-diff/members'><img src='https://gitee.com/codeleep/json-diff/badge/fork.svg?theme=white' alt='fork'></img></a>
8-
[![GitHub stars](https://img.shields.io/github/stars/codeleep/jsonDiff)](https://github.com/codeleep/jsonDiff/stargazers)
9-
[![GitHub forks](https://img.shields.io/github/forks/codeleep/jsonDiff)](https://github.com/codeleep/jsonDiff/network)
10-
[![GitHub issues](https://img.shields.io/github/issues/codeleep/jsonDiff)](https://github.com/codeleep/jsonDiff/issues)
8+
[![GitHub stars](https://img.shields.io/github/stars/codeleep/json-diff)](https://github.com/codeleep/json-diff/stargazers)
9+
[![GitHub forks](https://img.shields.io/github/forks/codeleep/json-diff)](https://github.com/codeleep/json-diff/network)
10+
[![GitHub issues](https://img.shields.io/github/issues/codeleep/json-diff)](https://github.com/codeleep/json-diff/issues)
1111

1212
</div>
1313

json-diff-common/src/main/java/me/codeleep/jsondiff/common/function/EqualsFunction.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

json-diff-common/src/main/java/me/codeleep/jsondiff/common/function/Function.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

json-diff-common/src/main/java/me/codeleep/jsondiff/common/model/Constant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class Constant {
1313
* 遍历所需常量
1414
***************************************************************************
1515
*/
16-
public static final String PATH_ROOT = "root";
16+
public static final String PATH_ROOT = "$";
1717
public static final String SIGN = ".";
1818
public static final String JOIN_SPILT = "@_^_@";
1919
public static final String NULL = "null";

json-diff-common/src/main/java/me/codeleep/jsondiff/common/model/TravelPath.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import me.codeleep.jsondiff.common.utils.PathUtil;
44

5+
import static me.codeleep.jsondiff.common.model.Constant.PATH_ROOT;
6+
57
/**
68
* @author: codeleep
79
* @createTime: 2023/03/05 01:33
@@ -35,7 +37,7 @@ public TravelPath(TravelPath parentPath, MappingKey mappingKey) {
3537

3638
public TravelPath(TravelPath parentPath, int expectIndex, int actualIndex) {
3739
// 抽象的路径
38-
this.abstractTravelPath = parentPath.getAbstractTravelPath() + PathUtil.getIndexPath("");
40+
this.abstractTravelPath = parentPath.getAbstractTravelPath() + PathUtil.getIndexPath("*");
3941
// 实际遍历的路径
4042
this.actualTravelPath = parentPath.getActualTravelPath() + PathUtil.getIndexPath(String.valueOf(actualIndex));
4143
this.expectTravelPath = parentPath.getExpectTravelPath() + PathUtil.getIndexPath(String.valueOf(expectIndex));
@@ -47,6 +49,12 @@ public TravelPath(String abstractTravelPath) {
4749
this.expectTravelPath = abstractTravelPath;
4850
}
4951

52+
public TravelPath() {
53+
this.abstractTravelPath = PATH_ROOT;
54+
this.actualTravelPath = PATH_ROOT;
55+
this.expectTravelPath = PATH_ROOT;
56+
}
57+
5058

5159
public TravelPath(TravelPath travel) {
5260
this.abstractTravelPath = travel.getAbstractTravelPath();
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package me.codeleep.jsondiff.common.utils;
22

33

4-
import java.util.regex.Matcher;
5-
import java.util.regex.Pattern;
6-
74
/**
85
* @author: codeleep
96
* @createTime: 2023/02/20 17:39
@@ -21,35 +18,8 @@ public static String getIndexPath(String index) {
2118
return ARRAY_SING_LEFT + index + ARRAY_SING_RIGHT;
2219
}
2320

24-
2521
public static String getObjectPath(String parentPath) {
26-
return parentPath + OBJECT_SING;
27-
}
28-
29-
30-
/**
31-
* 将下标填入path
32-
* @param path 路径地址
33-
* @param index 下标
34-
* @return
35-
*/
36-
public static String insertPathIndex(String path, int index) {
37-
if (path == null || path.length() == 0 || index < 0) {
38-
return path;
39-
}
40-
// 正则表达式匹配"]["
41-
Pattern pattern = Pattern.compile("\\]\\[");
42-
Matcher matcher = pattern.matcher(new StringBuilder(path).reverse());
43-
StringBuilder sb = new StringBuilder(path);
44-
sb.reverse();
45-
// 循环匹配"[]",并记录匹配到的最右边的位置
46-
if (matcher.find()) {
47-
// 记录第一个"[]"出现的位置
48-
int i = matcher.start();
49-
sb.insert(i + 1, index); // 在"[]"中间插入数字
50-
}
51-
return sb.reverse().toString();
22+
return parentPath.replaceAll("\\[\\d+]", "[*]") + OBJECT_SING;
5223
}
5324

54-
5525
}

json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/JsonDiffConstants.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

json-diff-core/src/main/java/me/codeleep/jsondiff/core/handle/object/ComplexObjectJsonNeat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ private void keySetConversion(Set<String> expectKeys, Set<String> actualKeys) {
7777
// 移除忽略的Path
7878
HashSet<String> ignorePath = RunTimeDataFactory.getOptionInstance().getIgnorePath();
7979
List<MappingKey> mappingKeys = keyMap.stream().filter(mappingKey -> {
80-
String actualTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getActualKey();
81-
String expectTravelPath = PathUtil.getObjectPath(travelPath.getAbstractTravelPath()) + mappingKey.getActualKey();
80+
String actualTravelPath = PathUtil.getObjectPath(travelPath.getActualTravelPath()) + mappingKey.getActualKey();
81+
String expectTravelPath = PathUtil.getObjectPath(travelPath.getExpectTravelPath()) + mappingKey.getExpectKey();
8282
if (ignorePath.contains(actualTravelPath) || ignorePath.contains(expectTravelPath) ) {
8383
return false;
8484
}

json-diff-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</dependency>
2727
<dependency>
2828
<groupId>cn.xiaoandcai</groupId>
29-
<artifactId>json-diff-core</artifactId>
29+
<artifactId>json-diff</artifactId>
3030
<version>${project.version}</version>
3131
<scope>compile</scope>
3232
</dependency>

json-diff-test/src/main/java/me/codeleep/jsondiff/test/MultAllArrayTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package me.codeleep.jsondiff.test;
22

33
import com.alibaba.fastjson2.JSON;
4-
import com.alibaba.fastjson2.JSONArray;
5-
import me.codeleep.jsondiff.core.DefaultJsonDifference;
4+
import me.codeleep.jsondiff.DefaultJsonDifference;
65
import me.codeleep.jsondiff.common.model.JsonCompareResult;
7-
import me.codeleep.jsondiff.core.config.JsonDiffOption;
8-
import me.codeleep.jsondiff.impl.ImplType;
96
import me.codeleep.jsondiff.test.model.MetaData;
107
import me.codeleep.jsondiff.test.dataFactory.ArrayDataFactory;
118
import org.slf4j.Logger;

0 commit comments

Comments
 (0)