Anuj,

Just to clarify, you want to route on the name of the element under
POSTransaction? Meaning, route "Order" to one place and "Refund" to another?

I'm not a JSON Path expert, but I can't come up with a way to get  just an
element name from JSON path, it is usually used to get the value of a known
path.

If you used $.POSTransaction. as the expression I think you would get back
everything under POSTransaction  including the "Order" or "Refund" part,
and
then in RouteOnAttribute you could use expression language to see what it
starts ${yourAttribute:startsWith('Order')} or maybe use contains() instead
of startsWith.

Another completely different option is to use the ExecuteScript processor
to write a Groovy/Jython/etc script that gets the name of the first element
under POSTransaction and adds it as an attribute.

-Bryan


On Thu, Jul 7, 2016 at 8:34 AM, Anuj Handa <[email protected]> wrote:

> Hi Folks,
>
> I have following two JSON documents and i would like to route them based
> on what the value is. In the below examples its order and refund. i want
> this to be dynamic as i can expect range of values.
>
> i was thinking of using EvaluateJsonPath and reading the Value of this
> field in the attribute. i was unable to get what Path expression should be
> .
>
> $.POSTransaction.* returns me the entire JSON and not just the Order value
>
> is it possible to make it dynamic ?  or is there a better/different  way
> to do this
>
> {
> "POSTransaction": {
> "Order": {
>
> {
> "POSTransaction": {
> "Refund": {
>
>
> Regards,
> Anuj
>

Reply via email to