On Fri, Mar 9, 2012 at 09:32, soupir <[email protected]> wrote:

> Hi !
> Currently, I'm writing an application that includes another project (a kind
> of status bar).
> My problem is the following :
> In the project I'm writing, I use QooXdoo and Json-RPC requests thanks to
> the qx.io.remote.Rpc class.
> In the project I'm including, its uses Prototype framework...
>
> The problem is in the construction of the RPC request. QooXdoo uses
> qx.lang.Json.stringify() method. But this method doesn't correctly work
> because of Prototype.
>
> My example : qx.lang.Json.stringify(
> {"service":"myService","method":"myMethod","id":1,"params":["param1",
> "param2"]} )
> Without importing Prototype framework, I get a string :
> "{"service":"myService","method":"myMethod","id":1,"params":["param1",
> "param2"]}"
> >From the time I've imported Prototype framework, I get another string :
>
> "{"service":"myService","method":"myMethod","id":1,"params":*"*[*\*"param1*\*",
> *\*"param2*\*"]*"*}"
>
> The problem is in the params key.
>
> I know, it's not your fault. You're not responsible of Prototype. I saw
> several topics about this problem.
>
> http://www.mail-archive.com/[email protected]/msg23944.html
>
> Do you know a solution ?
>

The qooxdoo qx.lang.Json class is actually a wrapper around either the
built-in JSON stringify and and parse methods, or a pure JavaScript
implementation. It sounds like Prototype may mucking with the toJSON()
methods used by the native JSON.stringify.

You can try explicitly setting use of the pure JavaScript implementation.
The following, issued after qx.lang.Json has completed loading (e.g., in
your main() method), should do it:

var jsonImpl = new qx.lang.JsonImpl();
qx.lang.Json.stringify = jsonImpl.stringify;
qx.lang.Json.parse = jsonImpl.parse;

Note that the JavaScript implementation is intended for use when the
browser does not natively support JSON. It will likely be considerably
slower than the native implementation if you are stringifying or parsing
large objects.

If Prototype is in fact modifying some object's toJSON() method, then this
won't fix the problem, because the pure JavaScript implementation
implements those as well. An alternative solution is to use Prototype's
JSON stringify and parse method. To do so, instead of setting
qx.lang.Json.stringify/parse to be qooxdoo's jsonImpl.stringify/parse, set
them to be Prototype's functions (assuming that Prototype provides similar
static functions), or write little wrappers that you set these references
to, that call the Prototype functions in whatever format they require.

Cheers,

Derrell
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to