Home > front end >  JSONPath Expression in wso2 esb
JSONPath Expression in wso2 esb

Time:10-18

I have a json payload that looks like below:

{
   "orders" : {
    "order.id" : 1024,
    "order.name" : "Ruffled-top"
}
}

I need to fetch order.id and order.name. Dot notation of JSONpath expression anyways won't work here. So I tried bracket notation like:

<property name="order-id" expression="json-eval($[orders][order.id])"/>

But the bracket notation is not working in wso2. Is there any other way this can be achieved? Thanks in advance.

CodePudding user response:

You need to have order.id surrounded by '' inside the []. To access the orders object you can use the dot notation as well.

<property expression="json-eval($.orders.['order.id'])" name="order-id" scope="default" type="STRING"/>

or

<property expression="json-eval($['orders']['order.id'])" name="order-id" scope="default" type="STRING"/>
  • Related