Skip to Content
0

REST Adapter: Problem converting JSON containing empty arrays

Jan 09 at 05:47 AM

122

avatar image
Former Member

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 ?

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

1 Answer

Anurag Gupta Jan 09 at 11:17 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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 ??

}

0

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

0