following response i'm getting rest
{ "category_id": 1314, "display_category_name": "", "english_category_name": "sports", "url_category_name": "" }, { "category_id": 13, "display_category_name": "art", "english_category_name": "art", "url_category_name": "art" }, { "category_id": 21, "display_category_name": "blogs", "english_category_name": "blogs", "url_category_name": "blogs" }
but need "category_id" , english_category_name
displayed how can extract 2 fields alone in c# ?
thanks in advance .
create following class:
public class category { public int category_id { get; set; } public string english_category_name { get; set; } }
use following library newtonsoft.json
deserialize jsonstring follows:
var categories = jsonconvert.deserializeobject<list<category>>(json);
you can access categories list of category objects i.e
var category = categories.firstordefault(); string categorydisplayname = category.english_category_name;
please note can rename fields in c# json types this:
[jsonproperty("english_category_name")] public string englishcategoryname { get; set; }
Comments
Post a Comment