Json-Net, JSON Date and time parse
So I've used a third party JSON serializer named Json-Net. It converts my DateTime objects into something like new Date(2031231023912)
inside a JSON string.
I, however, can't get any Javascript JSON parsers to parse it, since it is considered invalid JSON. Any ideas around it?
I guess I could manually send back 开发者_如何学Cthe ticks from the webservice I am hitting but that would be a pain. Hopefully there is a workaround.
The JSON format has no intrinsic concept of "date" as a data type. You have to know where the date values are in your deserialized objects, and you have to write the code that finds those and instantiates dates. You can represent the date as an epoch time or as a calendar string; it depends on the application (and it does make a difference).
Representing a date as a string like, "new Date(123456789)" seems like a particularly bad way to do things. It'd be simpler to just store the value.
精彩评论