-Fixed static values being included with fields serialization -Examples! (work in progress)
28 lines
720 B
C#
28 lines
720 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Newtonsoft.Json.Tests.Documentation.Examples
|
|
{
|
|
public class SerializeDateFormatHandling
|
|
{
|
|
public void Example()
|
|
{
|
|
DateTime mayanEndOfTheWorld = new DateTime(2012, 12, 21);
|
|
|
|
string jsonIsoDate = JsonConvert.SerializeObject(mayanEndOfTheWorld);
|
|
|
|
Console.WriteLine(jsonIsoDate);
|
|
// "2012-12-21T00:00:00"
|
|
|
|
string jsonMsDate = JsonConvert.SerializeObject(mayanEndOfTheWorld, new JsonSerializerSettings
|
|
{
|
|
DateFormatHandling = DateFormatHandling.MicrosoftDateFormat
|
|
});
|
|
|
|
Console.WriteLine(jsonMsDate);
|
|
// "\/Date(1356044400000+0100)\/"
|
|
}
|
|
}
|
|
} |