Search code examples
jmeterperformance-testing

Extracting 3 values using json extractor


i am new to performance testing, currently working on one scenario where we need to correlate id, field type & allowed_otypes(first value of the payload)

all of the these three variables are interlinked to each other, i need to pick id, field type & allowed_otypes in one json expression, if i do individually then then script is getting failed due to miss match in the passing of wrong values

[
    {
        "id": 12,
        "field_type": "DISPLAY_SET",
        "tooltip_text": null,
        "name_plural": "Approvers",
        "name_singular": "Approver",
        "backref_name": null,
        "backref_tooltip_text": null,
        "allow_multiple": true,
        "allowed_otypes": [
            "user",
            "groupprofile",
            "groupprofile"
        ],
        "options": null,
        "builtin_name": "approver",
        "can_view": null,
        "can_edit": null,
        "flavor": "DEFAULT",
        "tag_ds_id": null,
        "tag_schema_name": null
    },
    {
        "id": 10022,
        "field_type": "DATA_SET",
        "tooltip_text": "Approvers",
        "name_plural": "Approvers",
        "name_singular": "Approvers",
        "backref_name": "Approvers",
        "backref_tooltip_text": "Approvers",
        "allow_multiple": true,
        "allowed_otypes": [
            "profile",
            "groupprofile",
            "groupprofile"
        ],
        "options": null,
        "builtin_name": null,
        "can_view": null,
        "can_edit": null,
        "flavor": "DEFAULT",
        "tag_ds_id": null,
        "tag_schema_name": null
    }
]

need to pass correlated values in the next sampler individually, please help


Solution

  • It's not very clear what you're trying to achieve.

    If you want to extract a single set of variables for example for first item in the JSON Array you can do this using JSON Extractor configured like:

    • Names of created variables: id;field_type;allowed_otypes
    • JSON Path Expressions: [0].id;[0].field_type;[0].allowed_otypes[0]

    in this case you will have the following JMeter Variables created:

    allowed_otypes=user
    field_type=DISPLAY_SET
    id=12
    

    Demo:

    enter image description here

    More information: How to Use the JSON Extractor For Testing