Visual Studio 可以直接通过json数据来生成所对应的实体类,不需要手动去编写实体类。
具体操作步骤:
1、创建一个新的类文件
2、复制需要生成的json数据
3、在VS上依次选择:编辑?选择性粘贴->将JSON粘贴为类。(下图)
一段测试json数据
1 |
{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",<br>"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",<br>"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",<br>"county_id":"-1","isp_id":"100017"}}<br> |
其实也可以直接将XML数据转换成实体类
发布者:柚子,转转请注明出处:https://ityouzi.com/archives/visual-studio-auto-create-json.html