Ok , Thank you. On Tue, Dec 16, 2014 at 5:05 PM, Vanjikumaran Sivajothy <[email protected]> wrote: > > Since there is a bug in the milestone pack, I would recommend you to write > a class mediator and perform this task. > > > On Tue, Dec 16, 2014 at 4:25 PM, Elilmatha Sivanesan <[email protected]> > wrote: >> >> It is not working with m2,m3 >> >> On Tue, Dec 16, 2014 at 3:26 PM, Elilmatha Sivanesan <[email protected]> >> wrote: >>> >>> Yes now I'm running this with 4.9.0 m3 >>> >>> On Tue, Dec 16, 2014 at 3:19 PM, Vanjikumaran Sivajothy <[email protected]> >>> wrote: >>>> >>>> Can you please run this with ESB 4.9.0 m1/m2 ? >>>> >>>> On Tue, Dec 16, 2014 at 2:14 PM, Vanjikumaran Sivajothy <[email protected] >>>> > wrote: >>>>> >>>>> Hi elimatha, >>>>> If this is blocker to you, Have you try to use custom class mediator >>>>> to perform above job? >>>>> >>>>> Best regards, >>>>> vanji >>>>> >>>>> On Tue, Dec 16, 2014 at 2:03 PM, Elilmatha Sivanesan < >>>>> [email protected]> wrote: >>>>> >>>>>> >>>>>> Hi all, >>>>>> I need to convert the json string like the following {"name": >>>>>> {"is":"john"}} to {\"name\": {\"is\":\"john\"}} >>>>>> >>>>>> I wrote the javascript as follows which works well on the online java >>>>>> script editor. The script >>>>>> <!DOCTYPE html> >>>>>> <html> >>>>>> <body> >>>>>> <h2>Create Object from JSON String</h2> >>>>>> <p id="demo"></p> >>>>>> <script> >>>>>> var p ='{"name": {"is":"john"}}'; >>>>>> var x = p.replace(/\"/g,'\\"'); >>>>>> document.write(x); >>>>>> </script> >>>>>> </body> >>>>>> </html> >>>>>> >>>>>> So I wrote the script in the synapse configuration as below. >>>>>> <script language="js"><![CDATA[ >>>>>> var q = mc.getProperty('uri.var.query1'); >>>>>> <!--var o = JSON.stringify(q);--> >>>>>> var qReplacedString = q.replace(/\"/g,'\\"'); >>>>>> mc.setProperty('uri.var.query1',qReplacedString); >>>>>> ]]> >>>>>> </script> >>>>>> >>>>>> But it gives me the following errors. Is there any issues on using >>>>>> /\"/ character ,What would be the problem on this. >>>>>> >>>>>> ERROR - ScriptMediator The script engine returned an error executing >>>>>> the inlined js script function mediate >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> com.sun.phobos.script.util.ExtendedScriptException: >>>>>> org.mozilla.javascript.EvaluatorException: The choice of Java >>>>>> constructor replace matching JavaScript argument types (function,string) >>>>>> is >>>>>> ambiguous; candidate constructors are: >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> class java.lang.String >>>>>> replace(java.lang.CharSequence,java.lang.CharSequence) >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> class java.lang.String replace(char,char) (<Unknown Source>#4) in >>>>>> <Unknown >>>>>> Source> at line number 4 >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68) >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at javax.script.CompiledScript.eval(CompiledScript.java:92) >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:291) >>>>>> [2014-12-16 13:50:45,113] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:235) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:203) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.template.TemplateMediator.mediate(TemplateMediator.java:77) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:129) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.template.InvokeMediator.mediate(InvokeMediator.java:78) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77) >>>>>> [2014-12-16 13:50:45,114] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:255) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:556) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:198) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225) >>>>>> [2014-12-16 13:50:45,115] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at java.lang.Thread.run(Thread.java:722) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> Caused by: org.mozilla.javascript.EvaluatorException: The choice of Java >>>>>> constructor replace matching JavaScript argument types (function,string) >>>>>> is >>>>>> ambiguous; candidate constructors are: >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> class java.lang.String >>>>>> replace(java.lang.CharSequence,java.lang.CharSequence) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> class java.lang.String replace(char,char) (<Unknown Source>#4) >>>>>> [2014-12-16 13:50:45,116] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.Context.reportRuntimeError(Context.java:1030) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.Context.reportRuntimeError(Context.java:1086) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.Context.reportRuntimeError3(Context.java:1064) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.NativeJavaMethod.findFunction(NativeJavaMethod.java:442) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:157) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) >>>>>> [2014-12-16 13:50:45,117] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at org.mozilla.javascript.gen.c20._c0(<Unknown Source>:4) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at org.mozilla.javascript.gen.c20.call(<Unknown Source>) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at org.mozilla.javascript.gen.c20.call(<Unknown Source>) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at org.mozilla.javascript.gen.c20.exec(<Unknown Source>) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> at >>>>>> com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:55) >>>>>> [2014-12-16 13:50:45,118] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> ... 21 more >>>>>> [2014-12-16 13:50:45,119] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> [2014-12-16 13:50:45,114] ERROR - SynapseCallbackReceiver Synapse >>>>>> encountered an exception, No error handlers found - [Message Dropped] >>>>>> [2014-12-16 13:50:45,119] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> The >>>>>> script engine returned an error executing the inlined js script function >>>>>> mediate >>>>>> [2014-12-16 13:51:44,632] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> [2014-12-16 13:51:44,631] WARN - SourceHandler Connection time out >>>>>> after >>>>>> request is read: http-incoming-2 >>>>>> [2014-12-16 13:51:44,652] INFO >>>>>> {org.wso2.carbon.automation.core.utils.coreutils.InputStreamHandler} - >>>>>> [2014-12-16 13:51:44,652] INFO - DeploymentInterceptor Removing Axis2 >>>>>> Service: createSavedSearch {super-tenant} >>>>>> >>>>>> But the replace function works well in normal strings. eg >>>>>> <script language="js"><![CDATA[ >>>>>> var q = mc.getProperty('uri.var.query1'); >>>>>> <!--var o = JSON.stringify(q);--> >>>>>> var qReplacedString = q.replace("name","hi"); >>>>>> mc.setProperty('uri.var.query1',qReplacedString); >>>>>> ]]> >>>>>> </script> >>>>>> >>>>>> Thank You. >>>>>> -- >>>>>> *S.Elilmatha* >>>>>> Associate Software Engineer, >>>>>> >>>>>> WSO2 Inc.; http://wso2.com >>>>>> lean.enterprise.middleware >>>>>> >>>>>> Mobile 0779842221. >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> Dev mailing list >>>>>> [email protected] >>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>> >>>>>> >>>>> >>>>> -- >>>>> Sivajothy Vanjikumaran >>>>> *Senior Software Engineer* >>>>> *Integration Technologies Team* >>>>> *WSO2 Inc. http://wso2.com <http://wso2.com/>* >>>>> *Mobile:(+94)777219209* >>>>> [image: Facebook] <https://www.facebook.com/vanjikumaran> [image: >>>>> Twitter] <https://twitter.com/vanjikumaran> [image: LinkedIn] >>>>> <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image: >>>>> Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare] >>>>> <http://www.slideshare.net/vanjikumaran> >>>>> >>>>> This communication may contain privileged or other >>>>> confidential information and is intended exclusively for the addressee/s. >>>>> If you are not the intended recipient/s, or believe that you may >>>>> have received this communication in error, please reply to the >>>>> sender indicating that fact and delete the copy you received and in >>>>> addition, you should not print, copy, re-transmit, disseminate, or >>>>> otherwise use the information contained in this communication. >>>>> Internet communications cannot be guaranteed to be timely, secure, error >>>>> or virus-free. The sender does not accept liability for any errors >>>>> or omissions >>>>> >>>> >>>> >>>> -- >>>> Sivajothy Vanjikumaran >>>> *Senior Software Engineer* >>>> *Integration Technologies Team* >>>> *WSO2 Inc. http://wso2.com <http://wso2.com/>* >>>> *Mobile:(+94)777219209* >>>> [image: Facebook] <https://www.facebook.com/vanjikumaran> [image: >>>> Twitter] <https://twitter.com/vanjikumaran> [image: LinkedIn] >>>> <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image: >>>> Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare] >>>> <http://www.slideshare.net/vanjikumaran> >>>> >>>> This communication may contain privileged or other >>>> confidential information and is intended exclusively for the addressee/s. >>>> If you are not the intended recipient/s, or believe that you may >>>> have received this communication in error, please reply to the >>>> sender indicating that fact and delete the copy you received and in >>>> addition, you should not print, copy, re-transmit, disseminate, or >>>> otherwise use the information contained in this communication. >>>> Internet communications cannot be guaranteed to be timely, secure, error >>>> or virus-free. The sender does not accept liability for any errors >>>> or omissions >>>> >>> >>> >>> -- >>> *S.Elilmatha* >>> Associate Software Engineer, >>> >>> WSO2 Inc.; http://wso2.com >>> lean.enterprise.middleware >>> >>> Mobile 0779842221. >>> >>> >> >> -- >> *S.Elilmatha* >> Associate Software Engineer, >> >> WSO2 Inc.; http://wso2.com >> lean.enterprise.middleware >> >> Mobile 0779842221. >> >> > > -- > Sivajothy Vanjikumaran > *Senior Software Engineer* > *Integration Technologies Team* > *WSO2 Inc. http://wso2.com <http://wso2.com/>* > *Mobile:(+94)777219209* > [image: Facebook] <https://www.facebook.com/vanjikumaran> [image: Twitter] > <https://twitter.com/vanjikumaran> [image: LinkedIn] > <http://www.linkedin.com/pub/vanjikumaran-sivajothy/25/b31/293> [image: > Blogger] <http://vanjikumaran.blogspot.com/> [image: SlideShare] > <http://www.slideshare.net/vanjikumaran> > > This communication may contain privileged or other > confidential information and is intended exclusively for the addressee/s. > If you are not the intended recipient/s, or believe that you may > have received this communication in error, please reply to the > sender indicating that fact and delete the copy you received and in > addition, you should not print, copy, re-transmit, disseminate, or > otherwise use the information contained in this communication. > Internet communications cannot be guaranteed to be timely, secure, error > or virus-free. The sender does not accept liability for any errors > or omissions >
-- *S.Elilmatha* Associate Software Engineer, WSO2 Inc.; http://wso2.com lean.enterprise.middleware Mobile 0779842221.
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
