如何为以下json字符串创建C#类模型?

时间:2017-03-17 13:54:29

标签: json class

如何将json字符串转换为下面示例的各自的类模型。

请告诉我们如何将json的索引转换为类模型"1": {

{
    "caller_audio": {
        "errors": [],
        "lattice": {
            "1": {
                "links": {
                    "0": {
                        "start": 0,
                        "end": 0.44,
                        "weight": 0,
                        "word_confidence": 0.974111,
                        "best_path": true,
                        "word": "!ENTER",
                        "intensity": 0
                    }
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

将json的索引转换为类模型" 1":{应该使用IList。

public class LatticeModel
{
    public IList<LinksModel> Links { get; set; }
}
public  class LinksItemModel
{
     public string start { get; set; }

    public string end { get; set; }

    public string weight { get; set; }

    public string word_confidence { get; set; }

    public string best_path { get; set; }

    public string word { get; set; }

    public string intensity { get; set; }

}

public class LinksModel
{

    public IList<LinksItemModel> links { get; set; }
}