Skip to Content
0

Using JSON in Router

Jul 14, 2017 at 08:59 AM

107

avatar image

Hi guys, I am new to integration service and currently I am trying to set up a router in a scenario where I have a REST / JSON sender.

In the router I would like to check the value of a certain JSON element as the condition. I am not sure how to achieve this. I mean I could use an JSON/XML transformer and then have an xpath expression as the condition.. but as I also need JSON on the receiver side this doesn't make too much sense.

What would I need to do in order to evaluate a JSON element in the router conditon directly? Do I first need to write the JSON element I want to check to a property variable using a context modifier or is there some other way?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sriprasad Shivaram Bhat Jul 14, 2017 at 09:42 AM
1

Hello Peter,

Its not possible to set the value of JSON element directly in Content Modifier and Its not possible to refer the JSON element directly in Router too.

Best way is to have to Groovy Script and parse the Incoming JSON and set the property with required value to there only.

You can make use of jsonSlurper in your script to achieve the same.Below thread will give sample code with parsing JSON which you can utilize for your requirement with little tweak.

https://answers.sap.com/questions/168650/sap-hci-xml-to-json-converter-string-to-integer.html

Regards,

Sriprasad Shivaram Bhat

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Sriprasad, thank you for your reply!

I took and adjusted the groovy code and did some small changes in my iFlow. Now it is saving but not deploying ("Validation failed"). I am using the Webtool to work on the iFlow. Is it possible to get details anywhere regarding why Validation has failed?

I did not find any logs (also setting the trace to debug does not seem to do anything.. also the "tails" log in eclipse is empty). Or would I first need to export the whole iFlow from the Webtool and import it to Eclipse in order to see any details regarding errors during deployment?

Could the iFlow be read in eclipse directly or would it be some kind of file export (Webtool) and fileImport (Eclipse)?

0