cancel
Showing results for 
Search instead for 
Did you mean: 

REST Adapter: Problem converting JSON containing empty arrays

Former Member
0 Kudos

1) . We have a REST to REST Scenario, when the response is empty like below.

{ "main":

{ "row": [] }

}

2). The XML conversion is taking out 'row' tag and formed as below:

<Wrapper>

<main></main>

</Wrapper>

3). I have tried to add the 'row' tag in the message mapping and converting again the XML to JSON in the sender channel but the converted JSON Output is as follows

{ "main":

{ "row": [""] }

}

How to get rid of the extra "" (double quotes) with in the [ ] -->{ "row": [""] }

Same issue was mentioned in the below thread, however there is no solution at the end.

https://archive.sap.com/discussions/thread/3894034

Please see if you can help in any way ?

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hello,

Just for reference was able to solve this issue after following this SAP Note :

2505988 - Remove leading empty element in JSON Array after XML to JSON conversion

Thanks.

0 Kudos

Hello,

was this issue resolved ??

PRAGSMATIC
Participant
0 Kudos

In the conversion rules of the channel for Rest, you can define arrayType = true for the field 'row'

Former Member
0 Kudos

I have already defined the same in the channel and that's why I got the [ ] for 'row' , However, the issue is in case of empty result and the conversion from XML to JSON where I am getting extra " " .

1) When XML is as below :

<Wrapper>

<main></main>

<result></result> ----> I have added this tag in the message mapping.

</Wrapper>

2) JSON conversion is as below :

{ "main":

{ "row": [""] } ---> how to get the double quotes removed with in the Square brackets ??

}

PRAGSMATIC
Participant
0 Kudos

then in the message mapping do not generated result, if result value is empty ?