Hi Maz,
What is the JSON builder and formatter you are using? You can find them in
<Carbon_Home>/repository/conf/axis2/axis2.xml under Formatters and Builders.

Thanks,
Asanka

On Thu, Jan 8, 2015 at 8:14 PM, Bhathiya Jayasekara <[email protected]>
wrote:

> Hi Maz,
>
> I quickly tried out your config and it worked fine for me. I'm copying my
> full config here for your reference.
>
> <api xmlns="http://ws.apache.org/ns/synapse"; name="jsonTest"
> context="/json">
>    <resource methods="POST">
>       <inSequence>
>          <loopback></loopback>
>       </inSequence>
>       <outSequence>
>          *<script language="js">var older = mc.getPayloadJSON();     var
> newer=older;     mc.setPayloadJSON(newer);</script>*
>          <send></send>
>       </outSequence>
>    </resource>
> </api>
>
>
> *Request:*
> curl -X POST -d "{\"origin\":\"202.37.75.130\"}" -H "Content-Type:
> application/json" http://10.113.56.222:8281/json
>
> *Response:*
> {"origin":"202.37.75.130"}
>
> Hope this helps.
>
> Thanks,
> Bhathiya
>
> On Fri, Jan 9, 2015 at 3:55 AM, Maz Lakadia <[email protected]> wrote:
>
>> I am doing some very simple script mediation as a test to see if I can
>> change the payload being returned by my server.
>>
>> My unmediated payload comes out as:
>>
>> {"origin":"202.37.75.130"}
>>
>> Then I try doing a very simple check to see whether get and set work for
>> payloads:
>>
>> <script language="js">
>>     var older = mc.getPayloadJSON();
>>     var newer=older;
>>     mc.setPayloadJSON(newer);
>> </script>
>>
>> My result from this is:
>>
>> {"jsonObject":""}
>>
>> I have done testing that shows that setPayloadJSON() works, which means
>> that my getPayloadJSON must be returning an empty object.
>>
>> Looking at the log file shows this:
>>
>> ERROR {org.apache.synapse.mediators.bsf.ScriptMessageContext} -  JSON object 
>> is null. {org.apache.synapse.mediators.bsf.ScriptMessageContext}
>>
>> Is there anyone else having this error? Is this happening because the
>> Payload is actually a Java object rather than a JSON object?
>>
>>
>> Thanks,
>> Maz
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> *Bhathiya Jayasekara*
> *Software Engineer,*
> *WSO2 inc., http://wso2.com <http://wso2.com>*
>
> *Phone: +94715478185 <%2B94715478185>*
> *LinkedIn: http://www.linkedin.com/in/bhathiyaj
> <http://www.linkedin.com/in/bhathiyaj>*
> *Twitter: https://twitter.com/bhathiyax <https://twitter.com/bhathiyax>*
> *Blog: http://movingaheadblog.blogspot.com
> <http://movingaheadblog.blogspot.com/>*
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 


*Asanka DissanayakeSoftware Engineer*
*WSO2 Inc. - lean . enterprise . middleware |  wso2.com <http://wso2.com/>*

*email: [email protected] <[email protected]>,   blog:
cyberwaadiya.blogspot.com
<http://cyberwaadiya.blogspot.com>, asankastechtalks.wordpress.com
<http://asankastechtalks.wordpress.com>  mobile: +94 71 8373821*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to