Response:
[ { "rid": 2016, "userid": "abcd", "cid": "xyz", , "rname": "ijk", "des": null, "con": [{ "fname": "amnt_type", "op": "eqto", "vtype": "ENUM", "values": [{ "v1": "I", "v2": null, }, ], }, { "fname": "usd", "op": "GT", "vtype": "NUMERIC", "values": [{ "v1": "100.00", "v2": null } ] }, { "fname": "bcd", "op": "GT", "vtype": "ENUM", "values": [{ "v1": "101", "v2": null }, { "v1": "102", "v2": null }, { "v1": "678", "v2": null }, { "v1": "832", "v2": null }
]
}, {
"fname": "bcd",
"op": "GT",
"vtype": "ENUM",
"values": [{
"v1": "101",
"v2": null
}, {
"v1": "678",
"v2": null
}, {
"v1": "832",
"v2": null
}
]
}, {
"fname": "pcd",
"op": "EQ",
"vtype": "ENUM",
"values": [{
"v1": "ATM",
"v2": null
}, {
"v1": "KLX",
"v2": null
}, {
"v1": "MKH",
"v2": null
}
]
}
]
}, {
"rid": 876,
"userid": "abcd",
"cid": "xyz", ,
"rname": "Rule2",
"des": null,
"con": [{
"fname": "amnt_type",
"op": "GT",
"vtype": "ENUM",
"values": [{
"v1": "I",
"v2": null,
},
],
}, {
"fname": "bcd",
"op": "EQ",
"vtype": "ENUM",
"values": [{
"v1": "685",
"v2": null
}, {
"v1": "657",
"v2": null
},
]
},
]
}, {
"rid": 9875,
"userid": "abcd",
"cid": "xyz", ,
"rname": "PQR",
"des": null,
"con": [{
"fname": "amnt_type",
"op": "GT",
"vtype": "ENUM",
"values": [{
"v1": "I",
"v2": null,
},
],
},
]
}
]
ExpectedOutput:
{ { "rname": "ijk", "rid": 2016, "con": [{ "fname": "amnt_type", "op": "eqto", "vtype": "ENUM", "value": [ "I"
],
}, {
"fname": "usd",
"op": "GT",
"vtype": "NUMERIC",
"value": [
"100.00"
]
}, {
"fname": "bcd",
"op": "GT",
"vtype": "ENUM",
"value": [
"101", "102", "678", "832"
]
}, {
"fname": "pcd",
"op": "EQ",
"vtype": "ENUM",
"value": [
"ATM", "KLX", "MKH"
]
}
]
}, {
"rid": 876,
"rname": "Rule2",
"con": [{
"fname": "amnt_type",
"op": "GT",
"vtype": "ENUM",
"value": ["I"
],
}, {
"fname": "bcd",
"op": "EQ",
"vtype": "ENUM",
"value": [
"685", "657"
]
}
]
}, {
"rid": 9875,
"userid": "abcd",
"cid": "xyz", ,
"rname": "PQR",
"des": null,
"con": [{
"fname": "amnt_type",
"op": "GT",
"vtype": "ENUM",
"value": ["I"
],
},
],
},
}
Basically we need to capture all values under the values section and keep only value1 and combine it to it one array.
I am able to get rid,rname,con together but not able to achieve the value parameter.
I tried using JSON extractor, regular expression extractor still not able to get the output in desired format. Please help.
I am using groovy and Jmeter 5.0
If I correcltly got your requirement you could do something like:
Put the code to the JSR223 PostProcessor which needs to be a child of the Sampler which returns the original JSON
The generated JSON can be accessed as
${someVariable}where requiredMore information: