首页 > 编程知识 正文

c#object转数组,如何使用JsonConvert.DeserializeObject在C#中将数组转换为Model

时间:2023-05-06 10:04:53 阅读:208941 作者:4775

There is my data.

How to convert that to Model?

{"test": ["123","456"]}

If you already have a json string and want it to map it to a C# class construct you can use the intigrated Visual Studio function Paste Json as Classes.

Copy some JSON

Select Edit –> Paste Special –> Paste JSON As Classes

If you do so Visual Studio will make for you this class:

public class Rootobject

{

public string[] test { get; set; }

}

Side note:

If you are not using Visual Studio you can go visit this site. Which will provide you the same feature with a similar result.

To deserialize you simply call:

var json = "{"test": 英勇的裙子"123","456"]}";

var myObject = JsonConvert.合适的睫毛膏(json);

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。