0

I need the value out of an array, not the array brackets[ ]. Here is the JSON response I am trying to work with:

{
:   "@rpc":"1.0",
:   "@types":
:   [
:   :   "com.model.chart.PieChart",
:   :   "com.model.chart.PieChartData"
:   ],
:   "@data":
:   {
:   :   "@type":0,
:   :   "chartData":
:   :   [
:   :   :   {
:   :   :   :   "@type":1,
:   :   :   :   "data":0.0,
:   :   :   :   "name":"Yes"
:   :   :   },
:   :   :   {
:   :   :   :   "@type":1,
:   :   :   :   "data":13.0,
:   :   :   :   "name":"No"
:   :   :   }
:   :   ],
:   :   "subTitle":"Over Time Period",
:   :   "dataName":"MyData",
:   :   "title":"MyData Requirement"
:   }
}

I am trying to get just the data for the yes and no. So for no, I just want to get 13.0 but I continue getting [13.0] with the array brackets. Here are the values of JSONPath Expressions I have tried:

[email protected]..[?(@.name=='No')].data returns [13.0]

[email protected]..[?(@.name=='No')].data[0] returns nothing

[email protected]..[?(@.name=='No')][0].data returns nothing

[email protected][0]..[?(@.name=='No')].data returns nothing

I am using version 2.3 of the JSON plugin in my jmeter v 3.0. Any help is greatly appreciated.

2 Answers 2

1
  • Option 1: looking into the Debug Sampler given you use data as a reference name and receiving [13.0] you can get 13 without brackets as ${data_1}

    JMeter JSON Path Extractor

    • Option 2: since JMeter 3.0 you have JSON Path PostProcessor which behaves a little bit differently and returns the data without square brackets:

    JSON Path Postprocessor

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

Comments

1

I came across the same issue and using JMeter (version 3.2), I didn't get the square [] brackets. However, make sure you use "JSON Extractor" and not "jp@gc - JSON Path Extractor."

Comments

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.