Skip to content
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

[BUG]JSONPath.extract解析异常 #1215

Closed
pysenic opened this issue Mar 9, 2023 · 2 comments
Closed

[BUG]JSONPath.extract解析异常 #1215

pysenic opened this issue Mar 9, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@pysenic
Copy link

pysenic commented Mar 9, 2023

scala 2.11
fastjson 2.0.23

测试代码

object Test {

  def main(args: Array[String]): Unit = {

    val r =
      """
        |{"x":{},"message":"1"}
        |""".stripMargin

    println(JSONPath.extract(r, "$.x.y"))

  }
}

期望结果:null

Exception in thread "main" com.alibaba.fastjson2.JSONException: illegal fieldName input,, offset 9, character ,, line 2, column 10, fastjson-version 2.0.23

{"x":{},"message":"1"}

at com.alibaba.fastjson2.JSONReaderUTF16.readFieldNameHashCode(JSONReaderUTF16.java:1053)
at com.alibaba.fastjson2.JSONPathSegmentName.accept(JSONPathSegmentName.java:539)
at com.alibaba.fastjson2.JSONPathTwoSegment.extract(JSONPathTwoSegment.java:188)
at com.alibaba.fastjson.JSONPath.extract(JSONPath.java:73)
at Test$.main(Test.scala:22)
at Test.main(Test.scala)

以下写法结果都是null

object Test {

  def main(args: Array[String]): Unit = {

    val r =
      """
        |{"x":{},"message":"1"}
        |""".stripMargin

    println(JSONPath.eval(JSON.parseObject(r), "$.x.y"))

  }
}
object Test {

  def main(args: Array[String]): Unit = {

    val r =
      """
        |{"x":{},"message":"1"}
        |""".stripMargin

    println(JSONPath.eval(r, "$.x.y"))

  }
}
@pysenic pysenic added the bug Something isn't working label Mar 9, 2023
@wenshao wenshao added this to the 2.0.25 milestone Mar 9, 2023
wenshao added a commit that referenced this issue Mar 9, 2023
@wenshao
Copy link
Member

wenshao commented Mar 9, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.25-SNAPSHOT/
问题已修复,请帮忙用2.0.25-SNAPSHOT版本验证,2.0.25版本预计在3月中旬发布。

@wenshao wenshao added the fixed label Mar 9, 2023
@wenshao
Copy link
Member

wenshao commented Mar 12, 2023

@wenshao wenshao closed this as completed Mar 12, 2023
wenshao added a commit that referenced this issue Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants