Hi,

> Why is it that Prototype's JSON does not attempt to deserialize a date/
> time string that it actually serialized?

Because it has no way of knowing that that particular string is meant
to be a date.  We probably don't want the JSON deserializer to look at
every string value and make it a date if it happens to look like
one...  :-)

-- T.J.

On Sep 11, 6:29 pm, Kruncher <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Yes I totally agree with your comment regarding <http://asp.net/>
> Ajax!
>
> Thanks, that would be fantastic! :D
>
> Why is it that Prototype's JSON does not attempt to deserialize a date/
> time string that it actually serialized?
>
> var jsonDate = new String(new Date().toJSON());
> //===> jsonDate == "2008-09-11T17:14:20Z"
> var reverseDate = jsonDate.evalJSON();
> //===> reverseDate == "2008-09-11T17:14:20Z"   ??? Why is this not a
> Date object
>
> Many thanks Ryan and T.J.Crowder!
> Lea Hayes
>
> On Sep 11, 2:19 pm, "Ryan Gahl" <[EMAIL PROTECTED]> wrote:
>
> > Hi Kruncher... We use .NET with prototype (and Ext, jquery, etc)... it works
> > fine with any client libraries you want to use - just don't use their
> > ASP.NET <http://asp.net/> Ajax crap :)
>
> > Anyway...
>
> > We just override the Date serialization on the server. As you know, there
> > are already a vast number of built in Date.ToString() method overloads
> > possible in the .NET server side (which accepts a formatting string of
> > course).
>
> > We chose UTC (instead of ISO 8601 as TJ suggests)... and we just employ a
> > UTC string to Date converter on the client side (in our transport layer so
> > it's abstracted from the developer).
>
> > I'll talk to my guys and see if we can publish some of that code...
>
> > On Thu, Sep 11, 2008 at 2:01 AM, T.J. Crowder <[EMAIL PROTECTED]>wrote:
>
> > > Hi,
>
> > > > The ASP.NET date/time object generates the following JSON:
> > > >      dateModified":"\/Date(1220453756681+0100)\/"
>
> > > Unfortunately there is no JavaScript literal syntax for dates, and
> > > Crockford didn't add one for JSON because he was sticking to a
> > > language-neutral subset, so we have to rely on knowing the field is
> > > meant to be a date and interpreting strings.  Apparently ASP.Net has
> > > it's own...special..way of doing that, but I suspect you'll find that
> > > it's not compatible at the other end with anything but ASP.Net's own
> > > client-side JavaScript.  (Although it doesn't look particularly hard
> > > to figure out.)
>
> > > You'll have to solve this in your ASP.Net code, I'm afraid, or pre-
> > > process the JSON, or modify Prototype's JSON handling to recognise
> > > these dates. (And figure out what the format is -- why, oh why, can't
> > > people learn to use ISO 8601?!  It's a great fit for JSON, which is
> > > meant to be *human-readable*.)
>
> > > HTH,
> > > --
> > > T.J. Crowder
> > > tj / crowder software / com
>
> > > On Sep 11, 3:04 am, Kruncher <[EMAIL PROTECTED]> wrote:
> > > > Hi guys,
>
> > > > I am using the ASP.NET class DataContractJsonSerializer to transfer
> > > > information via the Prototype Ajax.Request and the server. Generally
> > > > this is working fantastically, however there is one problem, and I am
> > > > unsure whether it is something that I am doing wrong, or whether it is
> > > > something which is not yet available within the Prototype framework.
>
> > > > The ASP.NET date/time object generates the following JSON:
> > > >      dateModified":"\/Date(1220453756681+0100)\/"
>
> > > > Which Prototype appears to interpret as:
> > > >      dateModified: "/Date(1220453756681+0100)/"
>
> > > > Looking through the Prototype API documentation I found that it
> > > > converts JavaScript date/time objects into the form "yyyy-mm-
> > > > ddThh:mm:ssZ" but it does not seem to be able to automatically reverse
> > > > this back into a JavaScript date time object.
>
> > > > Any suggestions would be fantastic!
> > > > Lea Hayes
>
> > --
> > Ryan Gahl
> > Manager, Senior Software Engineer
> > Nth Penguin, LLChttp://www.nthpenguin.com
> > --
> > WebWidgetry.com / MashupStudio.com
> > Future Home of the World's First Complete Web Platform
> > --
> > Inquire: 1-920-574-2218
> > Blog:http://www.someElement.com
> > LinkedIn Profile:http://www.linkedin.com/in/ryangahl
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@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-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to