Hi Martin. For me definitely, the code should be changed. Imagine you
have the following object:

[{"key1": "value1"}, {"key1": "value2"}].

Eg, an array of objects. If the native toJSON method exists it will
return '[{"key1": "value1"}, {"key1": "value2"}]' exactly as a string
without the single quotes. This is probably what you want in the end
(in my case I send that to the server). If this is considered as a
string and converted again via qx.util.Json, this does not make any
sense (you obtain ' "{\"key1\": \"value1\"}, {\"key1\": \"value2\"}]"
' which does not make any sense to me (it's like you have a string,
whereas in fact what you care about is the array / objects.

So I definitely think qx.util.Json.stringify should have the same
behavior as a native toJSON method. Or am I missing something? I dont
see how you could possibly want qx.util.Json.stringify to behave
differently...

On Mon, Oct 4, 2010 at 9:32 AM, Martin Wittemann
<[email protected]> wrote:
> Good Morning Jean-Noël,
> I just checked that and it seems that the code was written on intension 
> exactly how it is. The unit test for that features shows that the custom 
> toJSON should return an string without the quotes and the quotes will be 
> added by the __convert call, as the key is.
> The native json method on the other hand returns the strings as it should be. 
> So the question is, should we change it? It would be easy because it seems to 
> be a not documented feature, right?
> Best,
> Martin
>
>
> Am 29.09.2010 um 19:55 schrieb Jean-Noël Rivasseau:
>
>> Hello
>>
>> It seems to me there is a bug in __convertObject() if the underlying
>> object already has a native toJSON implementation. Because in that
>> case you do:
>>
>> return this.__convert(incoming.toJSON(key), key); (l. 413 in Qx 1.2)
>>
>> whereas incoming.toJSON(key) already returns a String. So since it
>> will go into __convert again the return String will get extra quotes
>> and will be converted - clearly not what we want.
>>
>> I tried today not with a native implementation but with Prototype's
>> implementation and ran into a bug because of this.
>>
>> I think it is sufficient to change the line to:
>>
>>                           return incoming.toJSON(key);
>>
>> It works in my case anyway. Should I open a bug or someone will
>> analyze it and fix it right away?
>>
>> PS: I am still waiting for a wiki account to put our application in
>> the real life examples. If someone can make me an account that would
>> be great.
>>
>> --
>> Jean-Noël Rivasseau
>> Directeur
>> (1) 778 786 3460 / (33) 01 82 88 05 26
>> Kameleoon - morphing the web
>> http://www.kameleoon.com/
>>
>> ------------------------------------------------------------------------------
>> Start uncovering the many advantages of virtual appliances
>> and start using them to simplify application deployment and
>> accelerate your shift to cloud computing.
>> http://p.sf.net/sfu/novell-sfdev2dev
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>
> ------------------------------------------------------------------------------
> Virtualization is moving to the mainstream and overtaking non-virtualized
> environment for deploying applications. Does it make network security
> easier or more difficult to achieve? Read this whitepaper to separate the
> two and get a better understanding.
> http://p.sf.net/sfu/hp-phase2-d2d
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>



-- 
Jean-Noël Rivasseau
Directeur
(1) 778 786 3460 / (33) 01 82 88 05 26
Kameleoon - morphing the web
http://www.kameleoon.com/

------------------------------------------------------------------------------
Virtualization is moving to the mainstream and overtaking non-virtualized
environment for deploying applications. Does it make network security 
easier or more difficult to achieve? Read this whitepaper to separate the 
two and get a better understanding.
http://p.sf.net/sfu/hp-phase2-d2d
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to