I have webservice hosted on Azure which is returning a JSON object. The JSON response looks like this:
HERE is my JSON RESPONSE
{
"Results":{
"output1":{
"type":"table",
"value":{
"ColumnNames":[
"Accommadation",
"Sex",
"Age",
"SiblingsAndSpouse",
"ParentChild",
"Fare",
"Embarked",
"Scored Labels",
"Scored Probabilities"
],
"ColumnTypes":[
"Int32",
"String",
"Nullable`1",
"Int32",
"Int32",
"Double",
"String",
"Int32",
"Double"
],
"Values":[
[
"2",
"male",
"35",
"0",
"0",
"20",
"C",
"0",
"0"
],
[
"2",
"male",
"35",
"0",
"0",
"20",
"C",
"0",
"0"
]
]
}
}
}
}
Kindly tell me that how to convert this response to string in C#. I am new to this please help me out,help from you guys will be highly appreciated. Thanks!!
I'm guessing what your really asking is how do to deserialize the JSON. Use Newtonsoft's JSON library's DeserializeObject method and assign it to a dynamic object type.
dynamic dynamicObject= JsonConvert.DeserializeObject(json);
then you can reference each property individually.
string type = dynamicObject.Results.output1.type;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With