func GetMapValueByKey(key string, mapData map[string]interface{}) interface{} {
value, ok := mapData[key]
if ok {
return value
}
return nil
}
var transferList = mapTool.GetMapValueByKey("token_transfers", result)
for _, transfer := range transferList.([]interface{}) {
var block_timestamp = transfer.(map[string]interface{})["block_ts"]
var quantity = transfer.(map[string]interface{})["quant"]
var quantityDecimal = safemath.String_to_decimal(quantity.(string)).Div(safemath.String_to_decimal("1000000000000000000"))
var quantityString = quantityDecimal.String()
fmt.Println(block_timestamp, quantityString)
}
{
"total": 2,
"rangeTotal": 2,
"contractInfo": {},
"token_transfers": [
{
"transaction_id": "1cf69dca430c8b8ae3c3c24aa2bf8707477",
"block_ts": 1640057784000,
"from_address": "TSjRp2LTtuyVx9ygZ8KVSR",
"to_address": "TKdQQuUnhA8Ak8D8w2YeWdj",
"block": 36507755,
"contract_address": "TFHMVstk3JZhS6YVKY",
"quant": "100000000000000000000000",
"confirmed": true,
"contractRet": "SUCCESS",
"finalResult": "SUCCESS",
"revert": false,
"tokenInfo": {
"tokenId": "TFHMqKBygS6YVKY",
"tokenAbbr": "ETH",
"tokenName": "ETHCoin",
"tokenDecimal": 18,
"tokenCanShow": 1,
"tokenType": "trc20",
"tokenLogo": "https://coin.top/production/upload/logo/TFHMVstk3bZhLqKBygS6YVKY.png?t=1639808185156",
"tokenLevel": "0",
"issuerAddr": "TSjRp2Lx9ygZ8KxBUkG3YVSR",
"vip": false
},
"fromAddressIsContract": false,
"toAddressIsContract": false
},
{
"transaction_id": "99e5a00674e96393b9add285f",
"block_ts": 1640057766000,
"from_address": "TSjRp2LTtugZ8KxBUkG3YVSR",
"to_address": "TKdQiH76nhA8AkhR7xeWdj",
"block": 36507749,
"contract_address": "TFH1ygS6YVKY",
"quant": "100000000000000000000000",
"confirmed": true,
"contractRet": "SUCCESS",
"finalResult": "SUCCESS",
"revert": false,
"tokenInfo": {
"tokenId": "TFHMWdTtkj1abZhLqKVKY",
"tokenAbbr": "ETH",
"tokenName": "ETHCoin",
"tokenDecimal": 18,
"tokenCanShow": 1,
"tokenType": "trc20",
"tokenLogo": "https://coin.top/production/upload/logo/TFHMgS6YVKY.png?t=1639808185156",
"tokenLevel": "0",
"issuerAddr": "TSjRp2LTtuyvGYYVSR",
"vip": false
},
"fromAddressIsContract": false,
"toAddressIsContract": false
}
]
}
https://transform.tools/json-to-go