[ASK] C# Xamarin JSOn
String a = "{\"success\":1,\"message\":\"successfully created.\"}";
string b = "{"success":1,"message":"successfully created."}";
how to get value success and message in JSON ?
Given the class model of (via http://jsonutils.com):
public class Example
{
public int success { get; set; }
public string message { get; set; }
}
Usage:
var a = "{\"success\":1,\"message\":\"successfully created.\"}";
var example = JsonConvert.DeserializeObject<Example>(a);
Console.WriteLine($"{example.success} : {example.message}");
Output:
1 : successfully created.
aandbin the above? If your question is asking how to convert an object into JSON, JsonConvert.SerializeObject looks promising. stackoverflow.com/questions/16294963/… or stackoverflow.com/questions/15843446/…