每次写javaBean时,如果都手动写不仅耗时而且容易出错。接下来介绍一款在AS中自动生成JavaBean的工具——GsonFormat.
第一步、安装
1、找到插件目录 Plugins
```
File -> settings ->Plugins,输入GsonFormat 点击Search in repositories
```
2、选择GsonFormat插件,点击install。安装很快,安装好后,会提示重启AS,重启完毕后,就可以使用了
第二步、使用示例
1、新建javaBean 类,右键选择“Generate”,在目录中选择“GsonFormat”选项
json串示例(请求地址):
{
"error": false,
"results": [
{
"_id": "5c09ff7b9d2122308e7445d8",
"createdAt": "2019-03-19T05:47:06.598Z",
"desc": "瓦力多渠道打包的Python脚本测试工具,简单实用。 ",
"images": [
"http://img.gank.io/251946a6-06d7-46bb-8c3f-21ccb1b0b13d"
],
"publishedAt": "2019-03-19T05:47:10.201Z",
"source": "web",
"type": "Android",
"url": "https://github.com/yangchong211/YCWalleHelper",
"used": true,
"who": "潇湘剑雨"
},
{
"_id": "5c8747cf9d2122032f6b5aaf",
"createdAt": "2019-03-12T05:46:55.816Z",
"desc": "Flutter日益恒行,一篇入门级BaseWidget项目架构值得您的关注~",
"images": [
"http://img.gank.io/2aff8927-bd5d-4d8f-9fac-6e4ed2013c87"
],
"publishedAt": "2019-03-13T01:32:11.450Z",
"source": "web",
"type": "Android",
"url": "https://blog.csdn.net/iamdingruihaha/article/details/88319883",
"used": true,
"who": "潇湘剑雨"
}
]
}
2、在弹出框中输入json串,点击ok即可生成JavaBean
3、选择需要去掉的字段,默认全部生成
至此大功告成。