所有键值都不匹配 jsonschema
all key-values did not match for jsonschema
我有如下所示的 jsonschema :
{
"id": 0,
"rc": "51",
"product": {
"code": "28",
"label": "PLN",
"type": "electricity",
"ops": "PLN",
"nominal": 50000
},
"cust_id": "01428800200",
"order_id": "",
"ref_no": "2033930693200733",
"amount": 50000,
"price": 50000,
"created": -62135596800
}
这是我的模式验证
{
"id": "#number",
"rc": "#string",
"product": {
"code": "#string",
"label": "#string",
"type": "#string",
"ops": "#string",
"nominal": "#number"
},
"cust_id": "#string",
"order_id": "#string",
"ref_no": "#string",
"amount": "#number",
"price": "#number",
"created": "#number? _ < 0"
}
但我收到消息 reason: all key-values did not match
,但我认为我的模式是正确的,所以有人可以帮助我吗??
这对我有用,你的脚本一定有错误。将下面的内容粘贴到一个新的功能文件中,看看它是否适合你自己:
* def response =
"""
{
"id": 0,
"rc": "51",
"product": {
"code": "28",
"label": "PLN",
"type": "electricity",
"ops": "PLN",
"nominal": 50000
},
"cust_id": "01428800200",
"order_id": "",
"ref_no": "2033930693200733",
"amount": 50000,
"price": 50000,
"created": -62135596800
}
"""
* def schema =
"""
{
"id": "#number",
"rc": "#string",
"product": {
"code": "#string",
"label": "#string",
"type": "#string",
"ops": "#string",
"nominal": "#number"
},
"cust_id": "#string",
"order_id": "#string",
"ref_no": "#string",
"amount": "#number",
"price": "#number",
"created": "#number? _ < 0"
}
"""
* match response == schema
我有如下所示的 jsonschema :
{
"id": 0,
"rc": "51",
"product": {
"code": "28",
"label": "PLN",
"type": "electricity",
"ops": "PLN",
"nominal": 50000
},
"cust_id": "01428800200",
"order_id": "",
"ref_no": "2033930693200733",
"amount": 50000,
"price": 50000,
"created": -62135596800
}
这是我的模式验证
{
"id": "#number",
"rc": "#string",
"product": {
"code": "#string",
"label": "#string",
"type": "#string",
"ops": "#string",
"nominal": "#number"
},
"cust_id": "#string",
"order_id": "#string",
"ref_no": "#string",
"amount": "#number",
"price": "#number",
"created": "#number? _ < 0"
}
但我收到消息 reason: all key-values did not match
,但我认为我的模式是正确的,所以有人可以帮助我吗??
这对我有用,你的脚本一定有错误。将下面的内容粘贴到一个新的功能文件中,看看它是否适合你自己:
* def response =
"""
{
"id": 0,
"rc": "51",
"product": {
"code": "28",
"label": "PLN",
"type": "electricity",
"ops": "PLN",
"nominal": 50000
},
"cust_id": "01428800200",
"order_id": "",
"ref_no": "2033930693200733",
"amount": 50000,
"price": 50000,
"created": -62135596800
}
"""
* def schema =
"""
{
"id": "#number",
"rc": "#string",
"product": {
"code": "#string",
"label": "#string",
"type": "#string",
"ops": "#string",
"nominal": "#number"
},
"cust_id": "#string",
"order_id": "#string",
"ref_no": "#string",
"amount": "#number",
"price": "#number",
"created": "#number? _ < 0"
}
"""
* match response == schema