Reputation: 187
I have tried a feature from karatedsl like json-schema... For example I have a file json contain :
{
"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"
}
and I match that son like this :
"""
{
"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'
}
"""
but I get error with message "reason : all key-values did not match", how to fix it ??
Upvotes: 2
Views: 386
Reputation: 4239
Your schema has one incorrect value causing this failure,
id
should be "#number"
not "number"
Modified Schema:
"""
{
"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'
}
"""
Upvotes: 1