Q: How do I make Json.NET successfully convert this json date structure to C# DateTime?
Hello, I am trying to deserialize a return value from a method call on an existing Meteor.js app using the DDP protocol into a known/strict return structure.
I am using dynamics to implement most basic things, but, moving on to strict structures to get benefit from type safety and intelisense on C#s side.
However it is failing to successfully deserialize the Javascripts Date() into C#s DateTime using the ddp serialization structure for the javascripts Date():
"when": {
"$date": 1406886657338
}
Q: How do I make Json.NET successfully convert this json date structure to C# DateTime?
If a "protocol" middleware was possible, having DateTime to DDPs Date() would be awsome too.
My structures:
namespace xxxx.API.Structures
{
public struct loginParams
{
public string email;
public string apiClient;
}
public struct loginReturn
{
public string result;
public string session;
public string email;
public string user;
public DateTime when;
public string client;
}
}
The return value I want converted into loginReturn :
xxxx.DDP.Client.DDPClient.ConnectGS.AnonymousMethod__1 (err=(null), res={{
"result": "sucess",
"session": "v3gozkHgceoqGqsfd",
"email": "xxxx@gmail.com",
"user": "hueun3s8rKQWsoQDT",
"server": "Lnf3vAFaeoCiMWriY",
"when": {
"$date": 1406886657338
},
"client": "OfficialxxxxPlugin"
}}) in /Volumes/2TB/Files/Documents/Dropbox/Development/C#/xxxx/xxxx/xxxxAPI/xxxx.DDP.Client/DDPClient.cs:43