Thursday 17 May 2018

c# - i want to get particular field value from json

You can define your custom class:


internal class Data
{
public Rate rate;
}
internal class Rate
{
public float combined_rate;
}

And deserialize this string to object:


var s = new JavaScriptSerializer();
var o = s.Deserialize(json);
var value = o.rate.combined_rate;

Also, you can extract other values from your string, just add new fields to Data class.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...