Saturday, 15 May 2010

.net - JSON.Net serialization and custom objects -


So I was working toward serializing some of my objects to a fairly lightweight approach, and the use of NewtonSoft's JasonNet Was hoping to do.

The challenge is that I am trying to use a simple interface for serializing an IDictionary. T will be one of the many institutions in my domain in this case that everyone has a Gid ID (which creates its key in the dictionary).

The problem I have is JSON.Net is successfully sorted by the dictionary key value and the ID property of the stored objects, but none of HT's other properties (which, at this point, are all simple types) . My serialization code is much more accurate than the JSON.net website:

  string json = JsonConvert.SerializeObject (data, formatting indent); As "Data" I have said that there is an IDictionary, and T (for this test) is a "property" type which is just a Guid ID and a string name property. The output looks like this:  
  {"d1cb1764-66cd-4cfb-8f51-c0b8457ce00e": {"Id": "d1cb1764-66cd-4cfb-8f51-c0b8457ce00e"}}  

Thank you.


No comments:

Post a Comment