this question has answer here:
- how can parse json c#? 10 answers
i have json string
{ "issuccess": true, "responsemessage": "voucher code valid!", "responsedata": { "vouchername": "company", "vouchercode": "sss12", "vouchervalue": "100" } }
how can read json data in c# code?
you can deseralize json data in different ways.either make class json values or use dictionary , access data after serialization.
for code need add reference project "system.web.extensions.dll"
using system.web.script.serialization; var jss = new javascriptserializer(); var dict = jss.deserialize<dictionary<string,dynamic>>(jsontext);
you can access desired fields as
bool issuccess = convert.tobool(dict["issuccess"]); string vouchername = convert.tostring(dict["responsedata"]["vouchername"]);
Comments
Post a Comment