问题描述
我试图通过使用以下数据发出发布请求来从 https://wax.greymass.com/v1/chain/get_table_rows 获取数据:
{
code: "atomicdropsx",index_position: 1,json: true,limit: 1,lower_bound: null,reverse: true,scope: "atomicdropsx",table: "drops",upper_bound: null,},
我得到以下数据:
{
rows: [
{
drop_id: 75809,collection_name: 'buterusart13',assets_to_mint: [Array],listing_price: '0.99000000 WAX',settlement_symbol: '8,WAX',price_recipient: 'pd2r4.wam',fee_rate: '0.02000000000000000',auth_required: 0,account_limit: 0,account_limit_cooldown: 0,max_claimable: 5,current_claimed: 0,start_time: 0,end_time: 0,display_data: '{"name":"Marker donuts(common)","description":""}'
}
],more: true,next_key: '75808'
}
但是当我在帖子请求正文中更改 json: false
时,我得到了这个:
{
rows: [
'23280100000000003042be06ebabb23e01c8b8010000c09ee605000000000857415800000000085741580000000000009086037245aa7b14ae47e17a943f000000000000000000000000000500000000000000000000000000000000000000000000002e7b226e616d65223a2250696e6b20536b756c6c28636f6d6d6f6e29222c226465736372697074696f6e223a22227d'
],next_key: '75810'
}
现在这个字符串对我来说看起来像一个十六进制字符串,我试着像这样解码它:
const decode = () => {
const fromHexString = (hexString) =>
new Uint8Array(
hexString.match(/.{1,2}/g).map((byte) => parseInt(byte,16))
);
var uint8array = fromHexString(
"23280100000000003042be06ebabb23e01c8b8010000c09ee605000000000857415800000000085741580000000000009086037245aa7b14ae47e17a943f000000000000000000000000000500000000000000000000000000000000000000000000002e7b226e616d65223a2250696e6b20536b756c6c28636f6d6d6f6e29222c226465736372697074696f6e223a22227d"
);
var string = new TextDecoder().decode(uint8array);
return string;
}
但我得到了这个输出:
#(0B�뫲>ȸ��WAWAX��rE�{�G�z�?.{"name":"Pink Skull(common)","description":""}
我只是不知道如何将看似十六进制字符串转换为 json。
谁能告诉我如何将其转换为 json 对象
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)