Michael,

Does DateTime still automatically change the time zone from client to server?

You might recall that you and talked about this a few months ago.

In one of my projects, we ended up passing our data information as a string because the conversion was destroying our data (and causing huge amounts of confusion because the conversion was occurring transparently.)

Matthew

On 7/10/06, Michael Schwarz <[EMAIL PROTECTED]> wrote:

Hi,

as there was a little discussion about serialization of .NET types and
deserialization of these genereted JSON strings I have updated
Ajax.NET Professional (version 6.7.9.1 ) to allow parsing of new Date
statements, too. You can use the JSON generated string to do a
deserialization right after, now.

I tried to write some other tests to see how these three frameworks
compare when running serialize() and deserialze() methods. JSON.NET
was not able to serialize a simple DateTime instance. When using a
DateTime as property in a class it could be serialized, but
deserializing didn't work because of the wrong date format (which is
different here in Germany and a  lot of other countries). Atlas is
working similar to the AjaxPro serialization, but not using UTC.

I started to add more properties/fields to the Person class example to
see which .NET data types are really working?

[AjaxPro.AjaxNoTypeUsage]
public class Person
{
  public MyColor color = MyColor.Yellow;
  public MyColor2 color2 = MyColor2.Red;  // not working with Atlas
  public DateTime dt = DateTime.Now;
  public float f = 2.3F;
  public double d = 1.1;
  public int i = 999;
  public int[] I = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  public bool b = false;
  public char c = '@';
  public List<string> s = new List<string>();
  public decimal dec = 0.1M;
  public string S = "\r\n\t\f\b?{\\r\\n\"\'";

  public Person()
  {
    s.Add("Hello World");
    s.Add("öäüÖÄÜ\\'{new Date(12345);[EMAIL PROTECTED]");
    s.Add(" ");
  }
}

public enum MyColor
{
  Black, Red, Yellow, White
}

public enum MyColor2 : byte
{
  Black, Red, Yellow, White
}

The class above is only working with AjaxPro. JSON.NET and Atlas have
both problems with non-US formats like dates or the decimal seperator.
Compare following JSON outputs:

Ajax.NET Professional:

{"color":2,"color2":1,"dt":new Date( Date.UTC(2006,6,9,12,18,22,704)),
"f":2.3,"d":1.1,"i":999,"I":[1,2,3,4,5,6,7,8,9],"b":false,"c":"@",
"s":["Hello World","öäüÖÄÜ\\'{new Date(12345);[EMAIL PROTECTED]","           "],
"dec":0.1,"S":"\r\n\t\f\b?{\\r\\n\"'"}

JSON.NET:

{"color":2,"color2":1,"dt":"07/09/2006 14:18:22",
"f":2.3,"d":1.1,"i":999,"I":[1,2,3,4,5,6,7,8,9],"b":false,"c":64,
"s":["Hello World","öäüÖÄÜ\\'{new Date(12345);[EMAIL PROTECTED]","           "],
"dec":"0.1","S":"\r\n\?{\\r\\n\"'"}

Atlas:

{"color":2, MISSING color2!! "dt":new Date(1152454818040),
"f":2.3,"d": 1.1,"i":999,"I":[1,2,3,4,5,6,7,8,9],"b":false,"c":"@",
"s":["Hello World","öäüÖÄÜ\\\'{new Date(12345);[EMAIL PROTECTED]","           "],
"dec":0.1,"S":"\r\n\?{\\\r\\n\"\'"}

If you have a deep look in the JSON output you will see a lot of
different serializations. There are some that are ok if the
deserialization is only used for .NET, but using the JSON output in
_javascript_ it will very bad if you do not get a real Date object or if
a character is represented as the ASCII code (see JSON.NET that will
serialize the @ sign to 64): The color2 property is using a byte enum
which is not supported by Atlas, I simple removed this for the test
above.

Next, I tried to use the JSON output to create a new instance of the
Person class. Hm, again only Ajax.NET Professional is working correct.
Atlas cannot convert any value with a decimal seperator if it is using
non-US culture info.


--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
mailto: [EMAIL PROTECTED]


NRN: No Reply Necessary
RYN: Reply with 'Yes' or 'No'
AYQ: Answering Your question
ATC: Attachement is important
1QM: One Question Message
MQM: Multiple Question Message
FYA: For your Archive
FYI: For your information (NRN)
WFR: Waiting for your Reply/Advice/Permission
AET: Answer Expected Today/this Week/within a Month
RAF: Read and Forward (jokes, quotes, interesting)
----------------------------------------------
More information: http://opensubject.pbwiki.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to