android 自动生成bean,Android Studio之插件自动生成JavaBean

Android Studio 自动生成JavaBean插件-GsonFormat

步骤:

1. 下载GsonFormat.jar ,下载地址:https://plugins.jetbrains.com/plugin/7654-gsonformat/versions  选择Android Studio,Download进行下载

2.AS-File-Setting-Plugins-Install Plugins from Disk (设置图标)-添加已经下载好的GsonFormat.jar 文件 ,重启Android Studio

3.使用:ALT + INS ,选择GsonFormat 自动生成

需要注意的是:服务器有时会返回一些特别的数据,比如:

{

"data": {

"2020": {

"3": {

"detail": [

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559580",

"transaction_id": "1000115855598400555957888830482",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559505",

"transaction_id": "1000115855598400555950453325196",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559468",

"transaction_id": "1000115855598400555946814464581",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559447",

"transaction_id": "1000115855598400555944674404579",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559005",

"transaction_id": "1000115855598400555899936310856",

"user_id": "555984"

}

],

"total_amount": "0.10"

},

"4": {

"detail": [

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.10",

"recharge_time": "1586962136",

"transaction_id": "1000115855598400496213567390918",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.30",

"recharge_time": "1585951939",

"transaction_id": "1000115855598400495193648999875",

"user_id": "555984"

}

],

"total_amount": "0.40"

}

}

},

"error_code": "",

"msg": "",

"status": "success"

}

5744c16e9c981a8d939dcc5d48a31f16.png

这个时候咱们选择的数据是:

{

"detail": [

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559580",

"transaction_id": "1000115855598400555957888830482",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559505",

"transaction_id": "1000115855598400555950453325196",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559468",

"transaction_id": "1000115855598400555946814464581",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559447",

"transaction_id": "1000115855598400555944674404579",

"user_id": "555984"

},

{

"bank_id": "CCB",

"bank_name": "中国建设银行",

"card_num": "6217001210067335016",

"recharge_amount": "0.02",

"recharge_time": "1585559005",

"transaction_id": "1000115855598400555899936310856",

"user_id": "555984"

}

],

"total_amount": "0.10"

}

注意:这个时候只能对以上的数据进行使用插件生成,其他数据不可以生成。

也就是说:对于数个元素对象Object,只选择其中一个对象Object进行封装Bean 对象即可;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值