0
votes

I am using jmeter json extractor.

In my api response I am getting values for media type as either

Case 1

"mediaType": {
    "__t": "MMP.Data.FieldValueCollection, MMP.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
    "vs": 1,
    "v": "2457cae6-6851-4471-be84-74e0ba385ded",
    "vl": "Television"
},

Or

Case 2

"mediaType": null

I am using json extractor to extract the value of the media plan.

Below is the screen shot of the json extractor

IMAGE.

For the first case, I can see my variable var_1 is set to "Television" ; but for the second case, the variable name I am seeing in debug sampler is var i.e. without _1

For the second case as well, I would want my variable name to be var_1 set to null.

Is there a way I could handle this in json extractor itself?

2

2 Answers

0
votes

So, you want the variable name should be the same in both the cases. If you change your "Match No" from -1 to 1 in your JSON Extractor then the variable name should not contain "_1" and you will have the same name of the variable for both responses i.e. var

It depend on you whether to choose var or var_1 as a name for variable for further operation.

0
votes

If can add default value null using User Defined Variables

User Defined Variables element lets you define an initial set of variables

Just define once var1_1 with value null and it will remain null in case 2 and override with Television in case 1.