c# - List<> failing to serialize to JSON -


i using following c# class in asp.net mvc project:

public class zonemodel {     public int id { get; set; }     public int number { get; set; }     public string name { get; set; }     public bool linefault { get; set; }     public bool sprinkler { get; set; }     public int resistance { get; set; }     public string zoneversion { get; set; }     list<detectormodel> detectors { get; set; } } 

in 1 of controllers, have action return type of jsonresult, return list of zonemodel objects (populated database). detectors property contains data, when return list controller using return json(viewmodel);, list of detectors missing serialized response.

why detectors property not serializing json?

just clarify comment. properties need declared public members in order serialized either json.net or built-in javascriptserializer.

public class zonemodel {     public int id { get; set; }     public int number { get; set; }     public string name { get; set; }     public bool linefault { get; set; }     public bool sprinkler { get; set; }     public int resistance { get; set; }     public string zoneversion { get; set; }      // property not serialized since private (by default)     list<detectormodel> detectors { get; set; } } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -