0

Sample input as below:

[{"program":"C:/temp/abc.exe","actions":"9","file_name":"abc1","new_file_name":"newabc1","version":"2.0.0.0","product_name":"abc","description":"abc","eventdate":"20160601120000"},{"program":"C:/temp/abc.exe","actions":"9","file_name":"abc2","new_file_name":"newabc2","version":"2.0.0.0","product_name":"abc","description":"abc","eventdate":"20160601120000"}]

I need to parse this json array into string for use in the following http request as parameters. I new to jmeter and tried to follow the example in http://theworkaholic.blogspot.my/2012/05/json-in-jmeter.html but i can't seem to get the value of jsonResponse at last.

[UPDATE] [enter image description here]1

1 Answer 1

1

Your question is not clear enough, however here are some clues:

  1. If you need to store the whole response into a JMeter Variable for later re-use - go for Regular Expression Extractor configured as follows:

    • Reference Name: anythingMeaningful, i.e. jsonResponse
    • Regular Expression: (?s)(^.*)
    • Template: $1$
  2. If you need 2 separate JSON Objects from the array - JSON Path PostProcessor is available since JMeter 3.0

    • $.[0] - for 1st JSON Array item
    • $.[1] - for 2nd JSON Array item

      JSON Path PostProcessor Demo

  3. If you need anything else - use the same JSON Path PostProcessor. I would recommend getting familiarized with the following material:

Still no luck - update your question with exact details on how you need to re-use that JSON data in next request(s)

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for your prompt reply. I have attached screenshot to better explained by question.
Check out jmeter.log file - it normally contains some information regarding Beanshell error. Also try your code in try block and in catch block use something like log.error("Error", ex) - you will be able to see the stacktrace in jmeter.log file. Also JMeter comes with net.minidev.json, not with org.json - make sure you have the relevant jar in classpath. See How to Use BeanShell: JMeter's Favorite Built-in Component for details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.