如何从json响应解析一些数据?

时间:2019-01-02 20:19:37

标签: javascript node.js

我是nodejs的新手。我现在有这样的代码。

client.listSinceBlock(hash, function(err, info) {
    if (err) {
        console.error('Unable to get block info for: ', hash, ' got error: ', err);
        return callback(err);
    }

    var transactionsIds = info;

      console.log('txids ', transactionsIds);
});

回答下面的响应:

    { transactions:
   [ { account: '',
       txid: '925cb1434f64567539896ee370b8dfca7c46d5c0a7482f2ce85d8a9fea976411',
       abandoned: false },
     { account: '',
       txid: 'afda7a1d90310c8fea22dff809062c72754e58e1a1918a55e210c59ad8a9b11c',
       'bip125-replaceable': 'no' },
     { account: '',
       txid: '30053a0b819f03bc37626468ce27b718140ce2db6c054c84899c7db0cb62fa26',
       'bip125-replaceable': 'no',
       abandoned: false },
 ],
  removed: [],
  lastblock: 'some data' }

但是我需要从该响应中解析TXID,如下所示:

    {
  "tx": [

    "925cb1434f64567539896ee370b8dfca7c46d5c0a7482f2ce85d8a9fea976411",
    "afda7a1d90310c8fea22dff809062c72754e58e1a1918a55e210c59ad8a9b11c",
    "30053a0b819f03bc37626468ce27b718140ce2db6c054c84899c7db0cb62fa26"
  ],
}

有人可以帮助我吗?

0 个答案:

没有答案