Consider this:
You need this required namespaces:
using System.Web.Script.Serialization;
Consider this class:
[Serializable]
public class Foo
{
public int status { get; set; }
public string message { get; set; }
}
SerializableAttribute
is required to work with JavaScriptSerializer
USAGE
JavaScriptSerializer serializer = new JavaScriptSerializer();
// Deserialize
Foo foo = serializer.Deserialize<Foo>(json);
//now you have access to...
var status = foo.status;
var message = foo.message;
You may also deserialize with JavaScriptSerializer
in a Dictionary
. See this:
Dictionary<string, object> ds = serializer .Deserialize<Dictionary<string, object>>(json);
var status = ds["status"].ToString();
var message = ds["message"].ToString();