JsonPath解析java中的json错误

时间:2015-11-05 08:00:49

标签: java json regex parsing jsonpath

这是JSON:

{
"datas": {
    "selling": {
        "3": [
            26452067,
            31625950
        ],
        "206": [
            32381852,
            32489262
        ],
        "208": [
            458
        ],
        "217": [
            27364892
        ],
        "226": [
            30474109
        ]
    }
},
"status": 0
}

我的路径是$.datas.selling['3','206'].\*
我希望得到' 3'和' 206'数据。像这样的JSON:

[
    26452067,
    31625950,
    32381852,
    32489262
]

但现在它无法运作。错误消息是

  

多属性只能用作路径叶子:   $ ['数据'] ['销售'] [' 3',' 206']

我的JsonPath maven版本是2.0.0(JsonPath's test website)。

实际上JsonPath可以在0.9.1版本中运行,这是一个错误吗?

我该如何解决?

2015年12月1日 现在,JsonPath新版本解决了这个问题。 谢谢!

1 个答案:

答案 0 :(得分:-3)

我用这种方式,

import string
import math
def fourDigit():
    num = raw_input("Enter a 4 digit number: ")
    if (len(num) == 4 and string.digits == True):
        some = int(int(val[1]) + int(val[3]))
        print("The sum of the 1st and second term is: ")
    else:
       print("Error!")