下面是一个例子:
{
"BTC": {
"full_name": "Bitcoin TST",
"payin_enabled": true,
"payout_enabled": true,
"transfer_enabled": true,
"precision_transfer": "0.00000001",
"networks": [{
"network": "BTC",
"protocol": "OMNI",
"default": true,
"payin_enabled": true,
"payout_enabled": true,
"precision_payout": "0.00000001",
"payout_fee": "0.000725840000",
"payout_is_payment_id": false,
"payin_payment_id": false,
"payin_confirmations": 3
}]
},
"ETH": {
"full_name": "Ethereum TST",
"payin_enabled": true,
"payout_enabled": true,
"transfer_enabled": true,
"precision_transfer": "0.000000000001",
"networks": [{
"network": "ETHTEST",
"protocol": "",
"default": true,
"payin_enabled": true,
"payout_enabled": true,
"precision_payout": "0.000000000000000001",
"payout_fee": "0.003621047265",
"payout_is_payment_id": false,
"payin_payment_id": false,
"payin_confirmaIions": 2
}]
}
}
我需要在同一个对象中使用GSON动态解析BTC和ETH等等。我需要的java类结构如下:
private String symbol; //this would be BTC or ETH or MATIC
private String full_name;
提前感谢!
1条答案
按热度按时间szqfcxe21#
在高级别使用
HashMap
,然后将其他JSON属性存储在其他类中这里,在
Network
类中,default是保留关键字@SerializedName("default")
,它是以这种方式处理的要测试的代码