-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSONPath.extract同一个parser只有第一次成功 #114
Comments
要每次都new JSONReader,如下这样写: @Test
public void jsonPathTest() {
String seatString = "{\n" +
"\t\"flightId\":\"MH8633\",\n" +
"\t\"column\":\"C\",\n" +
"\t\"row\":\"19\"\n" +
"}";
JSONPath rowPath = JSONPath.of("$.row");
JSONPath colPath = JSONPath.of("$.column");
String row = (String)rowPath.extract(JSONReader.of(seatString));
assertEquals("19", row);
String col = (String)colPath.extract(JSONReader.of(seatString));
assertEquals("C", col);
} |
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson/2.0.2-SNAPSHOT @Test
public void test2() {
String seatString = "{\n" +
"\t\"flightId\":\"MH8633\",\n" +
"\t\"column\":\"C\",\n" +
"\t\"row\":\"19\"\n" +
"}";
JSONPath path = JSONPath.of("$['row','column']");
Object result = path.extract(
JSONReader.of(seatString));
assertNotNull(result);
assertEquals("[\"19\",\"C\"]", result.toString());
} 2.0.2版本预计明天发布 |
好的 多谢指点 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问 不同的JSONPath使用extract方法 提取同一个解析器的内容 第二次extract会得到null值 是BUG嘛 还是设定只能解析一次
The text was updated successfully, but these errors were encountered: