JSON response issues c# -


i have return json string in c# api follows like:

{ "model" : 4 , "lang" : "en_us", "parts" : [ { "id" : 1545, "name" : "part 1", "part_types" : { "type 1" : { "url" : "part.com/type1", "desc" : "has 6 bits" }, "type 2" : { "url" : "part.com/type2", "desc" : "has 7 bits." } } } ] }

i have basic structure like:

public class inventory {     public int model { get; set; }     public string lang { get; set; }     public part[] parts { get; set; } }  public class part {     public int id { get; set; }     public string name { get; set; }     public type types { get; set; } }  public class type {     public string url { get; set; }     public string desc { get; set; } } 

but keep receiving output like:

{ "model" : 4 , "lang" : "en_us", "parts" : [ { "id" : 1545, "name" : "part 1", "part_types" : { "url" : "part.com/type1", "desc" : "has 6 bits" } } ] }

i have 2 issues, 1 when run api can display 1 type , if try make list adds [...] in array don't want array have display tittle each type , details not in array form.

second issue under part_types can not work out how display name of part type before details. if try add class name set in class displayed , can not change it.

any appreciated.

if using visual studio 2012 , web tools 2012.2 or later, there feature called paste json classes can paste valid json code editor , select edit -> paste special -> paste json classes generate c# or vb.net classes generate pasted json structure.

read paste json classes’ in asp.net , web tools 2012.2 more information , instructions.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -