I am trying to extract key "count" from response data and write it's value (int) in CSV file.
I have used BeanShell PostProcessor for the same.
Below is script I have used:
count = vars.get("count");
f = new FileOutputStream("file path", true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(count);
f.close();
And JSON sample, I am trying to extract:
{"meta":{"message":"","is_error":false,"count":295,"next":"123","status":1000,"previous":""}
Doing this, "null" gets printed in CSV file.
Please let us know what am I missing here?
It supposed to be 295 gets printed in CSV file.
Check whether your extractor is fetching the correct value. Below, I have used the same code and used regular expression extractor to fetch the values from the json. It is working fine.
Hope it helps.
Update for Reg Ex
Regular expression config;-
Below is to test the regular expression. You can always test your regular expression in view result tree using RegEx Tester:-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With