JSONPath not working like it should
search cancel

JSONPath not working like it should

book

Article ID: 131792

calendar_today

Updated On:

Products

CA Release Automation - Release Operations Center (Nolio) CA Release Automation - DataManagement Server (Nolio)

Issue/Introduction

In Release Automation I tried to use the following 2 actions but they are not giving me the expected result.

Json - Execute Multiple Queries Using JSONPath
Json - Extract properties from a Json object

I tried the following different jsonpath expressions which should all have the same result but none of them outputted anything in RA. On jsonpath.com I do get the expected result.

$.application1[*].it
.application1[0].it[0]
$.['application1'][*].['it']

The error RA returns is always: Reason: JSONObject["$.['application1'][*].['it']"] not found.

In Release Automation I tried to use the following 2 actions but they are not giving me the expected result.

Json - Execute Multiple Queries Using JSONPath
Json - Extract properties from a Json object

I tried the following different jsonpath expressions which should all have the same result but none of them outputted anything in RA. On jsonpath.com I do get the expected result.

$.application1[*].it
.application1[0].it[0]
$.['application1'][*].['it']

The error RA returns is always: Reason: JSONObject["$.['application1'][*].['it']"] not found.

The error observed occurs when the JSON path in the first action in place of property.

Environment

CA Release Automation: 6.5 or higher

Resolution

Please find the correct usage configuration of this action

Action: Json - Extract properties from a Json object
Observation: Don't use JSON-path in this but just enter the property name you are looking for. For example I am looking for application1 and I know it will be returning an string Array. In case if you want to extract further as you can see the output in below action is another JSON object. The action only going to extract the first level properties.

Inputs:
Json Object { "application1": [ { "it": [ "it server application 1" ], "ft": [ "ft it server application 1" ], "stg": [ "stg server 1 application 1", "stg server 1 application 1" ], "prd": [ "prd server 1 application 1", "stg server 1 application 1" ] } ], "application2": [ { "it": [ "it server application 2" ], "ft": [ "ft it server application 2" ], "stg": [ "stg server 1 application 2", "stg server 2 application 2" ], "prd": [ "prd server 1 application 2", "stg server 2 application 2" ] } ] }
Property 1
Property 2
Property 3 
Array Property 1 application1
Array Property 3
Array Property 2
Outputs:
Property Value 1
Property Value 2
Property Value 3
Array Property Value 1 [{"prd":["prd server 1 application 1","stg server 1 application 1"],"stg":["stg server 1 application 1","stg server 1 application 1"],"it":["it server application 1"],"ft":["ft it server application 1"]}]
Array Property Value 2 []
Array Property Value 3 []

Action: Json - Execute Multiple Queries Using JSONPath
Observation: Here I used the JSON-Path you shared and all returned the correct value.
Inputs:
Json Object { "application1": [ { "it": [ "it server application 1" ], "ft": [ "ft it server application 1" ], "stg": [ "stg server 1 application 1", "stg server 1 application 1" ], "prd": [ "prd server 1 application 1", "stg server 1 application 1" ] } ], "application2": [ { "it": [ "it server application 2" ], "ft": [ "ft it server application 2" ], "stg": [ "stg server 1 application 2", "stg server 2 application 2" ], "prd": [ "prd server 1 application 2", "stg server 2 application 2" ] } ] }
JSONPath Query1 $.application1[*].it
JSONPath Query2 $.application1[0].it[0]
JSONPath Query3 $.['application1'][*].['it']
JSONPath Query10
JSONPath Query9
JSONPath Query8
JSONPath Query7
JSONPath Query6
JSONPath Query5
JSONPath Query4 
Outputs:
JSONPath Result1 [["it server application 1"]]
JSONPath Result2 it server application 1
JSONPath Result3 [["it server application 1"]]
JSONPath Result4
JSONPath Result5
JSONPath Result6