For some reason the following JSON string creates the correct number of records in the custom objects array, but does NOT populate the objects in the array with and values. Help appreciated!
JSON String
{
"Grids": [{ "CommitImporterGrid": {"CostDivisionCode": "DL", "CostDivisionKey": 5, "CostDivisionName": "Direct Labor", "SourceType": "Contractor", "CommitDollars": 202, "CommitHours": 113.12, "PercentComplete": 50.00, "TaxRate": 0, "IohRate": 0.01, "ConditionerRate": 0}}],
"ProjectKey": 571,
"AsOf": "1/1/2008 11:59:59 PM",
"WbsKey": 1327,
"FcrGroupKey": 26,
"ContractorKey": 11
}
The Deserializer
protected void btnSave_Click(object sender, EventArgs e)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
JsonViewer view = serializer.Deserialize<JsonViewer>(txtJson.Value);
// The LIST in the "view" object HAS records, but NO DATA?
}
The Custom Classes
public class JsonViewer
{
public JsonViewer()
{ }
public List<CommitImporterGrid> Grids { get; set; }
public Int32 ProjectKey { get; set; }
public String AsOf { get; set; }
public Int32 WbsKey { get; set; }
public Int32 FcrGroupKey { get; set; }
public Int32 ContractorKey { get; set; }
}
public class CommitImporterGrid
{
public CommitImporterGrid()
{ }
public String CostDivisionCode { get; set; }
public Int32 CostDivisionKey { get; set; }
public String CostDivisionName { get; set; }
public String SourceType { get; set; }
public Decimal CommitDollars { get; set; }
public Decimal CommitHours { get; set; }
public Decimal PercentComplete { get; set; }
public Decimal TaxRate { get; set; }
public Decimal IohRate { get; set; }
public Decimal ConditionerRate { get; set; }
}