Below is the payload where we need to store the value inside ABC->XYZ. Here "123456" is the dynamic key. Where this "123456" value is stored from previous api.
{
"123456": {
"Message": {
"messageId": "abcd
},
"ABC": {
"XYZ": "REQ123456"
}
},
}
I have tried with below snippet where I am getting value as "123456" instead of "REQ123456"
* def list = []
* def fun = function(k, v){ karate.appendTo('list', { key: k, val: v } )}
* karate.forEach(response, fun)
* def keys = $list[?(@.val.ABC.XYZ)].key
* print keys