cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering using JsonPath syntax

brianc0755
New Contributor

Hello everyone.  I have this json object

"wd:Academic_Period": {
        "@wd:Descriptor": "Summer 2021 (05/24/2021-08/07/2021)",
        "wd:ID": [
               {
                   "@wd:type": "WID",
                    "$": "d75e5035f5431001cbdce27c57290002"
               },
             {
                   "@wd:type": "Academic_Period_ID",
                   "$": "ACADEMIC_PERIOD_SUMMER_2021"
             }
        ]
}

I want the element from the "wd:ID" array where the type is "WID".  

I have tried this expression:  jsonPath($, "['wd:Academic_Period']['wd:ID'][?(['@wd:type'] == 'WID')]")  and many other variants but I cannot express what is needed.  This particular expresion returns a blank value.

How should I refer to @wd:type in this expression?

 

1 ACCEPTED SOLUTION

SpiroTaleski
Valued Contributor

@brianc0755 

Try with this expression: 

 jsonPath($, "['wd:Academic_Period']['wd:ID'][?(@['@wd:type'] == 'WID')]") 

View solution in original post

1 REPLY 1

SpiroTaleski
Valued Contributor

@brianc0755 

Try with this expression: 

 jsonPath($, "['wd:Academic_Period']['wd:ID'][?(@['@wd:type'] == 'WID')]")