将json反序列化为c#

将json反序列化为c#,c#,json,serialization,C#,Json,Serialization,我的C#sharp对象应该是什么样子,我想将下面的JSON字符串反序列化为C#对象 以下是VS2013中生成的内容 public class Rootobject { public string PersonId { get; set; } public string Name { get; set; } public Hobbiescollection HobbiesCollection { get; set; } } public class Hobbiescoll

我的C#sharp对象应该是什么样子,我想将下面的JSON字符串反序列化为C#对象


以下是VS2013中生成的内容

public class Rootobject
{
    public string PersonId { get; set; }
    public string Name { get; set; }
    public Hobbiescollection HobbiesCollection { get; set; }
}

public class Hobbiescollection
{
    public Hobby[] Hobby { get; set; }
}

public class Hobby
{
    public string type { get; set; }
    public int id { get; set; }
    public string description { get; set; }
}

您可以使用VS2012/2013功能编辑/粘贴特殊/粘贴JSON作为类来简化此过程。

以下是VS2013中生成的内容

public class Rootobject
{
    public string PersonId { get; set; }
    public string Name { get; set; }
    public Hobbiescollection HobbiesCollection { get; set; }
}

public class Hobbiescollection
{
    public Hobby[] Hobby { get; set; }
}

public class Hobby
{
    public string type { get; set; }
    public int id { get; set; }
    public string description { get; set; }
}

您可以使用VS2012/2013功能
编辑/粘贴特殊/粘贴JSON作为类
来简化此过程。

有一个在线工具,您可以从字符串中创建C#类

公共课爱好
{
公共字符串类型{get;set;}
公共int id{get;set;}
公共字符串说明{get;set;}
}
公共课业余爱好收藏
{
公共列表{get;set;}
}
公共类根对象
{
公共字符串PersonId{get;set;}
公共字符串名称{get;set;}
公共HobbiesCollection HobbiesCollection{get;set;}
}

有一个在线工具,你可以用你的字符串制作C#类

公共课爱好
{
公共字符串类型{get;set;}
公共int id{get;set;}
公共字符串说明{get;set;}
}
公共课业余爱好收藏
{
公共列表{get;set;}
}
公共类根对象
{
公共字符串PersonId{get;set;}
公共字符串名称{get;set;}
公共HobbiesCollection HobbiesCollection{get;set;}
}

我刚刚发布了一个关于json2csharp的答案,我发现你快了53秒。呵呵。这是一个伟大的工具!我刚刚发布了一个关于json2csharp的答案,看到你比我快了53秒。呵呵。这是一个伟大的工具!谢谢你的提示,非常感谢。谢谢你的提示,非常感谢。
public class Hobby
{
    public string type { get; set; }
    public int id { get; set; }
    public string description { get; set; }
}

public class HobbiesCollection
{
    public List<Hobby> Hobby { get; set; }
}

public class RootObject
{
    public string PersonId { get; set; }
    public string Name { get; set; }
    public HobbiesCollection HobbiesCollection { get; set; }
}