You can use the JsonConvert
class of Newtonsoft.JSON . The installation can be done directly by Visual Studio as NuGet package. Just run the following in the Package Manager:
Install-Package Newtonsoft.Json
To deserialize your JSON string in a practical and faster way, you can use a list of key pairs and values, such as:
var jsonString = GetJson();
var obj = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonString);
You can access the desired value this way:
obj["message"];
// retorna a string "authenticate"
Another way is to do more typed, creating the model of your JSON in the form of a structured object, such as:
public class MeuTipo {
public string message { get; set; }
}
So you can deserialize your JSON like this:
var jsonString = GetJson();
var obj = JsonConvert.DeserializeObject<MeuTipo>(jsonString);
And access it like this:
obj.message;
// retorna a string "authenticate"