Hi Bryan, Thats correct i want to route on element name so "ORDER" through one and "REFUND" to another. The reason is based on element name the structure of the JSON could be different so the subsequent processing depends on the element name.
Processing thousands of messages per minute which would be better using RouteonAttribute or ExecuteScript ? Since the entire JSON doc could come in the attribute if i use $.POSTransaction. i would think it would slow it down compared with if the attribute value only has "ORDER" Anuj On Thu, Jul 7, 2016 at 10:59 AM, Bryan Bende <[email protected]> wrote: > 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 >> > >
