c# - Customizing JSON serialized response -


i using json.net, getting following result of object in c#.

{"library": [     {         "key": "outfrmt",         "description": "level 1 description",         "label": "label 1",         "value": "value 1",         "id": 1     },     {         "key": "outfrmt",         "description": "level 2 description",         "label": "label 2",         "value": "value 2",         "id": 2     },     {         "key": "rqstypefrmt",         "description": "level 2 description",         "label": "label 2",         "value": "value 2",         "id": 2     } ]} 

however,

what expecting following:

{     "library": {         "new": [             {                 "label": "new",                 "value": 0,                 "description": "freshly submitted."             },             {                 "label": "new",                 "value": 0,                 "description": "freshly submitted."             }         ],         "old": [             {                 "label": "new",                 "value": 0,                 "description": "freshly submitted."             },             {                 "label": "new",                 "value": 0,                 "description": "freshly submitted."             }         ]     } } 

i can change class structure , do, don't know if can rid of property "key" string.

please note values stored in database. don't want hard code key properties , et al.

update: class structure follows:

[jsonobject(title = "library")]     public class codelibrary : identitybase     {         public string key { get; set; }         public string description { get; set; }         public string label { get; set; }         public string value { get; set; }     } 


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -