The TrackIt Web API (I can't change it) gives me this JSON inside a return object:
...
Notes: {
Note1: {
CreatedBy: "smarteam2"
...
},
Note2: {
CreatedBy: "smarteam2"
CreatedDate: "1/27/2014 2:37:36 PM"
...
}, ...
Where there are N number of notes. I can't figure out how to deserialize this using JSON.Net unless I do something that feels wrong like:
public class TrackItWorkOrderNotes
{
public TrackItWorkOrderNotes Note1 { get; set; }
public TrackItWorkOrderNotes Note2 { get; set; }
public string IsPrivate { get; set; }
public string FullText { get; set; }
public string WorkOrderNoteTypeId { get; set; }
}
And in the parent:
public class TrackitWorkOrder
{
public TrackItWorkOrderNotes Notes { get; set; }
public int Id { get; set; }
...
This "works" by using :
ti = JsonConvert.DeserializeObject<TrackItResponse<TrackitWorkOrder>>(responseString);
I think there must be a better way to get the notes without pre-defining N number of them in the object. I believe TrackIt might have made this difficult by not putting the "Notes" in an array, but is there a smarter way to do this?