我已经尝试过karatedsl的一项功能,例如json-schema ... 例如,我有一个文件json contains:
{
"level": "info",
"event": "biller.purchase",
"credential": "MallOn_v2",
"package": "aaaa",
"id": 41658,
"customer_id": "088810000000",
"elapsed_time": 201,
"transactionbillerid": 39124,
"paramrequest": {
"amount": "10000",
"customer_id": "088810000000",
"partner_name": "MallOn_v2"
},
"parsedresponse": {
"desc": "SUCCESS",
"rescode": "0",
"status": "success",
"transactionID": "511644294"
},
"responsecode": "00",
"price": 10000,
"amount": 10000,
"time": "2018-11-29T19:06:04.757550"
}
我这样匹配那个儿子:
"""
{
"level": '#string',
"event": '#string',
"credential": '#string',
"package": '#string',
"id": 'number',
"customer_id": '#string',
"elapsed_time": '#number',
"transactionbillerid": '#number',
"paramrequest": {
"amount": '#string',
"customer_id": '#string',
"partner_name": '#string'
},
"parsedresponse": {
"desc": '#string',
"rescode": '#string',
"status": '#string',
"transactionID": '#string'
},
"responsecode": '#string',
"price": '#number',
"amount": '#number',
"time": '#string'
}
"""
但是我收到错误消息“原因:所有键值都不匹配”,如何解决?
答案 0 :(得分:1)
您的架构中有一个不正确的值导致此失败,
id
应该是"#number"
而不是"number"
修改后的架构:
"""
{
"level": '#string',
"event": '#string',
"credential": '#string',
"package": '#string',
"id": '#number',
"customer_id": '#string',
"elapsed_time": '#number',
"transactionbillerid": '#number',
"paramrequest": {
"amount": '#string',
"customer_id": '#string',
"partner_name": '#string'
},
"parsedresponse": {
"desc": '#string',
"rescode": '#string',
"status": '#string',
"transactionID": '#string'
},
"responsecode": '#string',
"price": '#number',
"amount": '#number',
"time": '#string'
}
"""