Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从json数组中选择特定项?_Javascript_Jquery_Json_Ethereum - Fatal编程技术网

Javascript 如何从json数组中选择特定项?

Javascript 如何从json数组中选择特定项?,javascript,jquery,json,ethereum,Javascript,Jquery,Json,Ethereum,所以我的 弹出一个JSON文件,如下所示: getTransactionFromAddress(Address).then((res) => { console.log(res); }) 我想选择特定的项目,并在仪表板上显示值 我正试图通过以下方式实现: { status: '1', message: 'OK', result: [ { blockNumber: '11381906', timeStamp: '1607028366'

所以我的

弹出一个JSON文件,如下所示:

getTransactionFromAddress(Address).then((res) => {
  console.log(res);
})
我想选择特定的项目,并在仪表板上显示值

我正试图通过以下方式实现:

    {
  status: '1',
  message: 'OK',
  result: [
    {
      blockNumber: '11381906',
      timeStamp: '1607028366',
      hash: '0x8d549d97116373ef3a0fc5b1459232db75200c9b8a8a90c04bccfe8c5e91a7d9',
      nonce: '422',
      blockHash: '0x2d63d2c6b63bc6763ed7aa7df6aa7311be64a361c01d57c443496ccd4018bbdc',
      transactionIndex: '189',
      from: '0x692190b4a5d3524b6fed0465e7400c07d09db954',
      to: '0x88a7ef2f047f8b07c6c917a6fd1a13438e9d8424',
      value: '10000000000000000',
      gas: '42000',
      gasPrice: '38000000000',
      isError: '0',
      txreceipt_status: '1',
      input: '0x',
      contractAddress: '',
      cumulativeGasUsed: '12387171',
      gasUsed: '21000',
      confirmations: '1068839'
    }
但我什么也没有得到。有人能告诉我怎么做吗?

试试这个:

console.table([{
        "Time": res.result.timeStamp,
        "From": res.result.from,
        "To": res.result.to,
        "Gas": res.result.gasPrice,
        "Value:" : res.result.value
      }]);
考虑到您的结果是一个数据数组,并且其中只有一个对象,您应该使用括号注释,以便从该数组的第一个索引中提取数据

您应该解释代码工作的原因,而不仅仅是“试试这个”。
console.table([{
        "Time": res.result[0].timeStamp,
        "From": res.result[0].from,
        "To": res.result[0].to,
        "Gas": res.result[0].gasPrice,
        "Value:" : res.result[0].value
      }]);