Condition data fetch in databank using regular expression

ParasofttoudayaParasofttoudaya Posts: 200 ✭✭

Hi Team,
I have a situation to fetch the data based on another data value.

In this below example, i have to fetch the name which id matches with 555

{
"customerName" : "Che",
"AccountType" : "Savings",
"Country" : "Argentina",
"id" : "222"
} ,
{
"customerName" : "Nepolean",
"AccountType" : "Savings",
"Country" : "France",
"id" : "111"
},
{
"customerName" : "Hitler",
"AccountType" : "Savings",
"Country" : "Germany",
"id" : "555"
}

Comments

  • Thomas MooreThomas Moore Posts: 64 admin

    Hi Udaya,

    To do this, you will need to use a JSON Databank with a custom XPath value.

    The XPath you're looking for is going to be something like this:
    /root/customers[1]/item[id="555"]/customerName/text()

    Keep in mind that to make the above JSON valid, I had to wrap it in a root element, hence the "customers" in the XPath :smile:.

    Additionally if you need to, you also have the ability to parameterize the id that the XPath is looking for with ${dataColumn} notation, but note that if you do, you will no longer be able to use the Evaluate XPath option in the databank editor.

    Hope this helps!

  • ParasofttoudayaParasofttoudaya Posts: 200 ✭✭

    Thanks. We were trying by putting double quotes for id :(

Sign In or Register to comment.