Hi Senduran,

Thanks, That worked.

We are generating it inside a xslt where we can not use payloadFactory.

On Wed, Oct 5, 2016 at 12:24 PM, Rajith Vitharana <raji...@wso2.com> wrote:

> Hi Udara,
>
> Try using the config senduran mentioned inside a payloadfactory mediator.
> Sample would be as below.
>
> <property name="messageType" value="application/json" scope="axis2"/>
> <payloadFactory media-type="xml">
>    <format>
>        <response xmlns="">
>          <test1>sample1</test1>
>          <?xml-multiple?><bob>test</bob>
>          <test2>sample2</test2>
>        </response>
>    </format>
>    <args/>
> </payloadFactory>
>
> Thanks,
>
>
>
> On 5 October 2016 at 12:18, Udara Liyanage <ud...@wso2.com> wrote:
>
>> Hi Senduran,
>>
>> I need to create json array within synapse configs coz backend expects an
>> array
>>
>> On Wed, Oct 5, 2016 at 8:11 AM, Senduran Balasubramaniyam <
>> sendu...@wso2.com> wrote:
>>
>>> 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
>>>
>>
>>
>>
>> --
>>
>> 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
>>
>>
>
>
> --
> Rajith Vitharana
>
> Senior Software Engineer,
> WSO2 Inc. : wso2.com
> Mobile : +94715883223
> Blog : http://lankavitharana.blogspot.com/
> <http://wso2.com/signature>
>



-- 

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

Reply via email to