On Nov 15, 4:48 pm, "Malte Ubl" <[EMAIL PROTECTED]> wrote:
[...]
> The source code of the test is located 
> athttp://code.google.com/p/joose-js/source/browse/trunk/tests/12_storag...
> Interestingly the statement at line 49 succeeds. (It stringifies a
> Joose object to JSON and and deserializes it again)
> The statement on line 81, howevery, fails to produce correct JSON. The
> produced string looks like this:
> {"test":"[[object Object]]","another":{"a":1}
>
> When you set a firebug break point in Storage.js line 11 you can see
> that the code goes deeply into Prototype.js territory.

The "joose" object (the one that's being tested against) seems to have
`toJSON` method:

function () {
  return this.pack(Joose.Storage.TEMP_SEEN);
}

That method seems to return an object, rather than a string
representation of an object. Prototype's `Object.toJSON` just happens
to delegate its logic to passed object's `toJSON` (effectively letting
"joose" object decide "what to do"). "joose" object returned from
`toJSON` is then turned into "[[object Object]]" via
`Array.prototype.join` invoked on an array it's contained within (join
performs `toString` on each of array's items, if I'm not mistaken).

>
> Bye
> Malte

[...]

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to