Groovy provides us with many useful features. One of them that is definitely worth mentioning is the Native Handling of JSON.
Reading time: 3 minutes
Native handling of JSON with Groovy
In the recently published SAP PRESS E-Bite – “Developing Groovy Scripts for SAP Cloud Platform Integration”, that I had the pleasure of writing together with Vadim Klimov, we explained how to parse and generate JSON payloads using Groovy Scripts in CPI.
Many of you might be familiar with my open-source project, FormatConversionBean, that was initially available in PI since 2015, and later ported to CPI in 2018. JSON handling in those projects was implemented using a third-party library (https://github.com/stleary/JSON-java).
As we invested time to look into handling JSON with Groovy, it was only natural to revisit the implementation in FormatConversionBean for CPI.
FormatConversionBean for CPI release 2.2.0
I am pleased to say that with the latest release, it now uses Groovy’s built-in functionality instead of depending on the third party library. As a bonus, a minor feature was added allowing JSON fields to be forced as arrays using GPath notation (another Groovy native capability). If you ever need a handy Swiss-army-knife like a tool to handle your conversion needs (XML, JSON, Excel, flat files) in CPI, check it out on GitHub.
Isn’t Groovy great? I think it is. And it is also feature-packed!
If you want to learn more, explore our E-Bite: https://bit.ly/37BSL9R.