空手道:如何遍历 JSON 有效载荷并打印每个字段值的长度
Karate: How to iterate through JSON payload and print length of values of each field
我有一个要求,我想打印 JSON 有效负载中所有字段值的字符长度。
例如负载是:
{
"request": {
"tranRef": "1234",
"sender": {
"firstName": "Johnny",
"lastName": "Doe",
"address": {
"city": "Arlington",
"country": "USA"
},
"organizationName": "Unity"
},
"type": "Merchant"
}
}
it would print something like
tranRef >> 4
sender.firstName >> 6
sender.lastName >> 3
sender.address.city >> 9
sender.address.country >> 3
sender.organizationName >> 5
type >> 8
不支持。自己写 Java interop code or you might be able to get somewhere with the JSON transforms: https://github.com/intuit/karate#json-transforms
空手道是一个测试框架,而不是通用编程语言。
我有一个要求,我想打印 JSON 有效负载中所有字段值的字符长度。
例如负载是:
{
"request": {
"tranRef": "1234",
"sender": {
"firstName": "Johnny",
"lastName": "Doe",
"address": {
"city": "Arlington",
"country": "USA"
},
"organizationName": "Unity"
},
"type": "Merchant"
}
}
it would print something like
tranRef >> 4
sender.firstName >> 6
sender.lastName >> 3
sender.address.city >> 9
sender.address.country >> 3
sender.organizationName >> 5
type >> 8
不支持。自己写 Java interop code or you might be able to get somewhere with the JSON transforms: https://github.com/intuit/karate#json-transforms
空手道是一个测试框架,而不是通用编程语言。