cancel
Showing results for 
Search instead for 
Did you mean: 

Error While converting JSON to XML in SAP CPI/CI

0 Kudos
2,451

Hi Experts,

I'm working on a scenario where I'm receiving JSON input and would like to convert it into XML and push it to S4 HANA system. When I use the standard JSON to XML convertor , I receive the below error as the sender system is not sending the JSON in proper format. Sender is not ready to handle this at their end and needs to be handled in the middleware.

In such a scenario , Could someone guide me how this can be handled please?

Incoming JSON from Sender System: (incorrect format due to missing double quotes for date BEGDA & ENDDA)

{"I_BEGDA":2020-01-01,"I_ENDDA":2020-01-21,"I_TOTAL":"X"}

Error While using Standard convertor:

com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $.I_BEGDA

Can any one guide me how this JSON can be converted to the correct JSON format please?

Correct JSON expected as input to the standard convertor

{"I_BEGDA":"2020-01-01","I_ENDDA":"2020-01-21","I_TOTAL":"X"}

Highly appreciate your responses

Thanks,

Priyanka

View Entire Topic
0 Kudos

Hi donepuna , priyanka2018 ,

Thanks much for the help above. Everything working as expected with the code above apart from one scenario. When the I_BEGDA & I_ENDDA values are the same, The script does not work as expected. Any clues here how to rectify this please?

Ex :{"I_BEGDA":2020-01-01,"I_ENDDA":2020-01-01,"I_TOTAL":"X"}

With this input, I'm getting additional double quotes. Request your kind help .

Output :

{"I_BEGDA":""2020-01-01"","I_ENDDA":""2020-01-01"","I_TOTAL":"X"}

Thanks,

Priyanka