Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to apply an x-path into an array.

Options
Neil
Neil Posts: 38

below is the sample JSON response, I want to get the documentid whose "subcategory" : "Loans" only

i tried below, didn't work out.
//documents/documentId[subcategory="Loans"]/text()

I want to apply a condition on subcategory field and retrieve only document id which satisfy the condition mentioned.

{
"documents" : [
{
"documentId" : "FO85L_rlLqZbYIKYznec2kazlBDVh7zcvQeJ9ocxYPLlqd_LRYIHTqPg6q8",
"formName" : "Entente relative au prêt personnel CIBC",
"ingestionDate" : "2017-02-03",
"fileSize" : 205820,
"note" : "Different",
"mimeType" : "application/pdf",
"products" : [
{
"accountNumber" : "0007508061",
"transitNumber" : "00153",
"closedDate" : null,
"category" : "LENDING",
"subcategory" : "Loans"
}
]
},
{

    {
        "documentId" : "nVr94RcSPG7b03E6b-7SvK9HbIyg3Vr53nAqmKipEtR2j87DzHi3bjosEK7r",
        "formName" : "Demande de fermeture de compte pour consolidation de dettes",
        "ingestionDate" : "2017-02-03",
        "fileSize" : 88552,
        "note" : "Demande de fermeture de compte pour consolidation de dettes",
        "mimeType" : "application/pdf",
        "products" : [
            {
                "accountNumber" : "6244831",
                "transitNumber" : "00153",
                "closedDate" : null,
                "category" : "LENDING",
                "subcategory" : "PLC"
            }
        ]
    },
    {

        ]
    }
]

}

Comments

  • jakubiak
    jakubiak Posts: 804 admin
    Options

    Try /root/documents/item/documentId[../products/item/subcategory/text()="Loans"]/text()

  • Neil
    Neil Posts: 38
    Options

    Thank You Jakubiak..:)