VUGEN Search for a specific value in a JSON file on Object1 and then return Object2 if criteria matches

38 Views Asked by At

I have the below dynamic JSON response Payload stored in a parameter

{
    "result": [
        {
            "batchNo": 214796,
            "clientName": "Luke Enterprise LLC",
            "code": "13106",
            "accountId": 5683,
            "invoices": 1,
            "inUseBy": "",
            "amount": 123

        },
        …….,
        {
            "batchNo": 214857,
            "clientName": "Account MASTER",
            "code": "20057",
            "accountId": 13761,
            "invoices": 2,
            "inUseBy": "Luke",
            "amount": 123
        },
            
    ],
    "statusCode": 200,
    "message": null
}

I am trying to retrieve the "batchNo" where it matches the following conditions.

  • "inUseBy" is ""
  • "amount" is 123

I've tried using the below code but it's giving me an error

lr_eval_json("Buffer={JsonData}",
        "JsonObject=json_obj", LAST);

    i = lr_json_find("JsonObject=json_obj",
        "Value=.*",
        "QueryString=$.result[*].batchNo",
        "UseRegExp=Yes",
        LAST);

can you please advise? Thank you!

0

There are 0 best solutions below