I'm trying to deserialize my Firefox bookmarks so I can do things with them. Surprisingly, this worked flawlessly:
class Bookmark
{
public string title;
public int? id;
public int? parent;
public string dateAdded;
public string lastModified;
public string type;
public string root;
public string uri;
public List<Bookmark> children;
}
class Program
{
static void Main(string[] args)
{
var jss = new JavaScriptSerializer();
var json = File.ReadAllText(@"T:\bookmarks-2012-08-08.json");
var root = jss.Deserialize<Bookmark>(json);
}
}
I can inspect the "root" object and everything comes out fine. The dates, however, look something like "1260492675000000". I'd like to convert those to DateTime
objects instead. I'm guessing those are just stored as number of milliseconds to epoch, which should be easy enough to convert, but how would I implement a custom deserializer for just those two date fields without compromising the rest of the fields, which were done for me automagically?