cancel
Showing results for 
Search instead for 
Did you mean: 

Need to convert a nested XML input to a JSON formatted single String

0 Kudos

Dear experts ,

We have a requirement to convert a deeply nested input structure to single target field that contains a JSON formatted string for request message creation and for response message we need to convert it back to the original same nested structure xml format from the Json formatted String via mapping .

This needs to be sent to Oracle using Advantco REST adapter for synchronous POST operation. standard conversion does not help much here and the same can not be passed directly from source SAP system as a single field due to business impact on existing code .

below is the details for source xml field -

<accessSchedule><properties> <schedule> <items> <properties> <daysOfWeek> <items> <enum>SAT</enum> </items> </daysOfWeek> <hours> <items> <items>07:00:00</items> </items> </hours> <hours> <items> <items>12:00:00</items> </items> </hours> </properties> <exceptDates> <items>2019-03-27</items> </exceptDates> </properties> </accessSchedule>

Source Message structure from SAP

while the desired target field is as follows -

<accessSchedule>"{\"schedule\":[{\"daysOfWeek\":[\"Mon\",\"Tue\"],\"hours\":[[\"07:00\",\"12:00\"]]}]</accessSchedule>

Looking forward to your suggestions !

Thanks in advance

Deepanshu

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Vinay,

Yes,I tried that option already and tried the data format conversion as per advantco guide. Since,we are using Advantco REST with PI7.3. However, Both ways , It returns an error 'Array element received, Expected value 'String' . I also raised it to Advantco where they have suggested to use the JSON body template in adapter then change the source field to single string field only and pass the inner JSON object as a encoded string as mentioned above. changing the source structure is not possible for now.

Not sure , if this is feasible to achieve using SAP PO REST adapter ?

Thanks

Deepanshu

0 Kudos

Hey Deepanshu,

Did you find solution for this, I have similar requiremebt.After converting to JSON I have to add escape characters in JSON structure except root element.

Also we have to convert it to base64 for and pass that as string value to another JSON structure.

Thanks in advance.

Regards,

Priyanka

vinaymittal
Contributor
0 Kudos

Did you try declaring all the nodes which have multiple occurrences as “array” inside the receiver communication channels data format tab?

Just need to put true in istypearray column

Regards

Vinay