有效的jsonpath给出UnsupportedOperationException,无法解析CriteriaType

时间:2019-05-03 06:22:19

标签: java jsonpath

此JsonPath

$.accounts[?('abc' in @.contact_ids)].user_id

在Java中运行时出错:

  

com.jayway.jsonpath.InvalidPathException:java.lang.UnsupportedOperationException:无法解析CriteriaType

但在使用{ay}实施的https://jsonpath.herokuapp.com/上完美运行。

异常跟踪:

at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:157)
at com.jayway.jsonpath.JsonPath.<init>(JsonPath.java:99)
at com.jayway.jsonpath.JsonPath.compile(JsonPath.java:426)
at com.jayway.jsonpath.internal.JsonReader.read(JsonReader.java:135)
Caused by: java.lang.UnsupportedOperationException: CriteriaType  can not be parsed
    at com.jayway.jsonpath.Criteria$CriteriaType.parse(Criteria.java:333)
    at com.jayway.jsonpath.Criteria.create(Criteria.java:807)
    at com.jayway.jsonpath.Criteria.parse(Criteria.java:755)
    at com.jayway.jsonpath.Filter.parse(Filter.java:175)
    at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyzeCriteriaSequence4(PathCompiler.java:284)
    at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyze(PathCompiler.java:262)
    at com.jayway.jsonpath.internal.PathCompiler$PathComponentAnalyzer.analyze(PathCompiler.java:236)
    at com.jayway.jsonpath.internal.PathCompiler.compile(PathCompiler.java:145)
    ... 37 more

示例json就是这样,尽管错误与json无关:

{
  "accounts": [
    {
      "user_id": "mail1@hotmail.com",
      "contact_ids": [
        "101",
        "102",
        "103",
        "104",
        "114",
        "115",
        "123"
      ]
    },
    {
      "user_id": "mail2@hotmail.com",
      "contact_ids": [
        "135",
        "156",
        "159"
      ]
    }]}

1 个答案:

答案 0 :(得分:-1)

请忽略。在我的项目中,我对2.0版有种种悬念。