Hi,

If any of the above does not work use a class mediator to do generate the
json payload required.

eg:-

    public boolean mediate(MessageContext mc) {
    StringBuilder sb = new StringBuilder();

    //generate the required payload

    org.apache.axis2.context.MessageContext axis2MC =
((Axis2MessageContext)mc).getAxis2MessageContext();
    JsonUtil.newJsonPayload(axis2MC, sb.toString(), true, true);
        return true;
    }

[1] https://docs.wso2.com/display/ESB481/Class+Mediator

Best Regards,
Malaka


On Wed, Aug 13, 2014 at 1:18 PM, Jay <janaka.n.ranathu...@gmail.com> wrote:

> Hi Malaka,
>
> My initial payload is as follows:
>
> <payloadFactory media-type="xml">
>         <format>
>                 <jsonObject xmlns="">
>                         <name>Janaka</name>
>                         <description>Desc</description>
>                         <status>open</status>
>                         <leadUser>A</leadUser>
>                         <currency>LKR</currency>
>                         <cust>114520</cust>
>                         <?xml-multiple?><tags></tags>
>                 </jsonObject>
>
>         </format>
>         <args />
> </payloadFactory>
>
> In script I'm adding some additional parameters (value and tags.tags should
> be send as array even if there are only one) to above payload as:
>
> **
>
> This will work properly if user send tags in request. But my problem is if
> user doesn't send tags parameter "tags" element will remove from payload
> and
> <?xml-multiple?> is applying to value element and it will send as array
> which back end will not accept. I have two options,
> [1]. Remove <?xml-multiple?> from payload if user doesn't send any tags
> [2]. Add PIs in Script mediator  other than in payloadFactory.
>
> What is your idea to solve this problem?
>
> Regards,
> Janaka
>
>
>
> --
> View this message in context:
> http://wso2-oxygen-tank.10903.n7.nabble.com/ESB-Problems-sending-numeric-keys-in-JSON-Payloads-tp99789p101325.html
> Sent from the WSO2 Development mailing list archive at Nabble.com.
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>



-- 

Best Regards,

Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Tel : 94 11 214 5345
Fax :94 11 2145300
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
Blog : http://mrmalakasilva.blogspot.com/

WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
http://www.wso2.com/about/team/malaka-silva/
<http://wso2.com/about/team/malaka-silva/>

Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to