如何使用JSON.NET将字符串转换为JSON



[ASK] c# Xamarin JSOn

String a = "{"success":1,"message":"successfully created."}";
string b = "{"success":1,"message":"successfully created."}";

如何在JSON中获得值成功和消息?

给定(via http://jsonutils.com):)的类模型

public class Example
{
    public int success { get; set; }
    public string message { get; set; }
}

用法:

var a = "{"success":1,"message":"successfully created."}";
var example = JsonConvert.DeserializeObject<Example>(a);
Console.WriteLine($"{example.success} : {example.message}");
输出:

1 : successfully created.

相关内容

  • 没有找到相关文章

最新更新