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