-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jsonpath support multi-names exists filter
- Loading branch information
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/src/test/java/com/alibaba/fastjson2/issues_2100/Issue2190.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.alibaba.fastjson2.issues_2100; | ||
|
||
import com.alibaba.fastjson2.JSON; | ||
import com.alibaba.fastjson2.JSONObject; | ||
import com.alibaba.fastjson2.JSONPath; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
||
public class Issue2190 { | ||
@Test | ||
public void test() { | ||
String str = "{\"code\":0,\"errMsg\":\"\",\"Data\":{\"is_focus\":1,\"user_info\":{\"userid\":\"13814\",\"nickname\":\"没事改昵称\"}}}"; | ||
JSONObject jsonObject = JSON.parseObject(str); | ||
assertSame(jsonObject, JSONPath.eval(jsonObject, "[?exists(@.Data.user_info.userid)]")); | ||
assertNull(JSONPath.eval(jsonObject, "[?exists(@.Data.user_info.userid1)]")); | ||
assertNull(JSONPath.eval(jsonObject, "[?exists(@.Data.user_info1.userid)]")); | ||
assertNull(JSONPath.eval(jsonObject, "[?exists(@.Data1.user_info.userid)]")); | ||
} | ||
} |