受欢迎的博客标签

How to Generate C# classes from JSON

Published

aaa

1.Generate C# classes from JSON  online web tool.

https://json2csharp.com/

Generate C# classes from JSON Class Name Attributes                                      None                                   None                                   DataMember                                   JsonProperty                                                       Enter the Json stringGenerate Generated

C# classes      

 public class FansList     {        

 public int type { get; set; }        

 public string fans_uname { get; set; }         public string avatar_url { get; set; }         public string intro { get; set; }         public int user_type { get; set; }         public int is_vip { get; set; }         public int follow_count { get; set; }         public int fans_count { get; set; }         public int follow_time { get; set; }         public int pubshare_count { get; set; }         public object fans_uk { get; set; }         public int album_count { get; set; }     }     public class RootObject     {         public int errno { get; set; }         public int request_id { get; set; }         public int total_count { get; set; }         public IList<FansList> fans_list { get; set; }     }

2.use vs2017,first copy json ,then execute below. Visual Studio 2017 (with ASP.NET and Web Tools 2012.2 RC installed) supports this natively. Visual Studio 2017 onwards have this built-in.   .

 

3.How can I format JSON document in Visual Studio ?

You could copy your code into a blank JSON file using the menus. I'm using Microsoft Visual Studio Community 2022.

File -->New-->File-->Web-->JSON File

 

JSON Formatter

json formatter 插件是一款能格式化json代码,使得json代码页面变得便于阅读的chrome json格式化插件,安装了这款插件后需要为该插件添加允许访问文件网址的权限以自动允许插件功能,之后该插件将会为你打开的json网页文件自动执行代码格式化、树状折叠以及缩进等功能。

https://mp.weixin.qq.com/s/aoEmwFwBwZReXCEUPKJC1A

https://github.com/callumlocke/json-formatter