I have this JSON:
{  
    "CutCenterId":1,
    "Name":"Demo Cut Center",
    "Description":"Test",
    "IsAvailable":true,
    "E2CustomerId":"110000",
    "NumberOfMachines":2,
    "Machines":[]
}
I have the following POCO:
public class CutCenter
{
    int CutCenterId { get; set; }
    string Name { get; set; }
    string Description { get; set; }
    bool IsAvailable { get; set; }
    string E2CustomerId { get; set; }
    int NumberOfMachines { get; set; }
}
I try the following line of code where json is set to the above JSON and _cutCenter is a member variable.
_cutCenter = JsonConvert.DeserializeObject<CutCenter>(json);
After this _cutCenter is set to all defaults. Why? What am I doing wrong?
Your members are all private. Try this.
public class CutCenter
{
    public int CutCenterId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public bool IsAvailable { get; set; }
    public string E2CustomerId { get; set; }
    public int NumberOfMachines { get; set; }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With