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
Post a Comment