Hi Udara,

I tried the following API and the request, (I am using ESB 500)
API:

<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse";
     name="XMLtoJSON"
     context="/XMLtoJSON">
   <resource methods="POST">
      <inSequence>
         <property name="messageType" value="application/json"
scope="axis2"/>
         <respond/>
      </inSequence>
   </resource>
</api>


Request:

curl -v -d '<jsonObject><?xml-multiple addresses?></jsonObject>'
http://localhost:8280/XMLtoJSON -H "Content-type: application/xml"

Regards
Senduran


On Tue, Oct 4, 2016 at 6:36 PM, Udara Liyanage <ud...@wso2.com> wrote:

> Hi Senduran,
>
> Below is xslt snippet I tried.
>
>       <xsl:choose>
>         <xsl:when test="count(addresses)=0">
>           <jsonObject>
>             <?xml-multiple addresses?>
>           </jsonObject>
>         </xsl:when>
>
> On Tue, Oct 4, 2016 at 6:26 PM, Udara Liyanage <ud...@wso2.com> wrote:
>
>> Hi Senduran,
>>
>> That I tried already. But it produced
>>
>> {"root":null}
>>
>> On Tue, Oct 4, 2016 at 5:37 PM, Senduran Balasubramaniyam <
>> sendu...@wso2.com> wrote:
>>
>>> Hi Udara,
>>>
>>> You can get an empty addresses array by following:
>>>
>>> <jsonObject>
>>>    <?xml-multiple addresses?>
>>> </jsonObject>
>>>
>>> Regards
>>> Senduran
>>>
>>> On Tue, Oct 4, 2016 at 12:09 PM, Udara Liyanage <ud...@wso2.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I want to generate an empty json array ("addresses":[]) when addresses
>>>> count is zero. I tried below as [1] which resulted only in null.
>>>>
>>>>
>>>>      <xsl:if test="count(addresses)=0">
>>>>         <jsonObject>
>>>>           <jsonArray></jsonArray>
>>>>         </jsonObject>
>>>>       </xsl:if>
>>>>
>>>>
>>>> [1] https://docs.wso2.com/display/ESB500/JSON+Support
>>>>
>>>>
>>>> --
>>>>
>>>> Udara Liyanage
>>>> Software Engineer
>>>> WSO2, Inc.: http://wso2.com
>>>> lean. enterprise. middleware
>>>>
>>>> Blog: http://udaraliyanage.wordpress.com
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> Dev@wso2.org
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> *Senduran *
>>> Senior Software Engineer,
>>> WSO2, Inc.;  http://wso2.com/ <http://wso2.com/>
>>> Mobile: +94 77 952 6548
>>>
>>
>>
>>
>> --
>>
>> Udara Liyanage
>> Software Engineer
>> WSO2, Inc.: http://wso2.com
>> lean. enterprise. middleware
>>
>> Blog: http://udaraliyanage.wordpress.com
>>
>
>
>
> --
>
> Udara Liyanage
> Software Engineer
> WSO2, Inc.: http://wso2.com
> lean. enterprise. middleware
>
> Blog: http://udaraliyanage.wordpress.com
>



-- 
*Senduran *
Senior Software Engineer,
WSO2, Inc.;  http://wso2.com/ <http://wso2.com/>
Mobile: +94 77 952 6548
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to