doubo4336 2016-06-25 11:28
浏览 101
已采纳

无法解码此json字符串

Hello I have trouble decoding this json string. I want the data in the addr tab in inputs. I got this far but cant quite seem to get it to work. As it says that he cant find the index: prev_out.

$obj = json_decode($json, true);
print_r($obj['inputs']['prev_out']['addr']);

Thanks in advance! Json is below:-

{
   "ver":1,
   "inputs":[
      {
         "sequence":4294967295,
         "prev_out":{
            "spent":true,
            "tx_index":157297076,
            "type":0,
            "addr":"39ijp4Gm1u5eobUXDvFeUkptCxzM4wTvB9",
            "value":3586445,
            "n":4,
            "script":"a914581463827ce1916221a1f353fb25e0dc7af9d74187"
         },
         "script":"00483045022100b378dbd0d597e5c60ae0a3f7b94a19c60513c089539c6a19f4d2a7ee8a5b153d022008e1d49e1b15930a7ecf9344b608dc914094261d9c07c43c717c7c80c98c99b501483045022100e20fa265371ab054c3d979d059573072768bde511c9679f60fb60e2c2b02d8c30220458238a0eac9edf65a95366284c32cd45868493de061eeb0d33160d7d9440c59014c6952210216d0dab96b694c0e51c74ecc5cfd0edbd33e95174a7868f898759034f4328a4d2103d74f67411d6690ecbb8be003fcf57a169f71d5a49f397436687ba90b4869b6cd2103737a0d04533d229f40666f5e9b51788132cef4a4cdec1f081a083eab0a1ec51d53ae"
      }
   ],
   "block_height":417889,
   "relayed_by":"52.91.197.204",
   "out":[
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1JyRD8nE91Rx2yf8vHsEHSFMNk2HmdTWJX",
         "value":7000,
         "n":0,
         "script":"76a914c525a41987a122946c0e3b9b4bd4635da34bb86188ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1M9RQMhnH1LsRBW2oUNDHJvv8RQHUZUexP",
         "value":16000,
         "n":1,
         "script":"76a914dcfa36b68d55cb3648e0b7f8a50fe66c8a72716488ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"17jUxesmxoALuwg7Ui2w9sdoce3P7LLgL1",
         "value":25250,
         "n":2,
         "script":"76a91449d99085d647d4e51654277f2e617220f50b6f6388ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1DPyjr4hDmFi8Li72gKhX5Ho9krA8wn2un",
         "value":13500,
         "n":3,
         "script":"76a91487fa060eee997531ccbd0659870d69f8ce61150088ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1Gb9mzKZF6vG9HDLitDHWobC4tDwrEV7ZH",
         "value":11000,
         "n":4,
         "script":"76a914aaff5ae1e6b2a36e87919ab92189db3bfccaf72f88ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1NrQBQHFoQi6BjixVe5TFXMFsnLrg5THTn",
         "value":26000,
         "n":5,
         "script":"76a914efb25f6aa111385094f9f015b37dc9f6c3cc8e7388ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"35jSyba4y8J9yisvKYkLMSMH4wyu5GXxhz",
         "value":13500,
         "n":6,
         "script":"a9142c563f7997b1e78548a7373c508dd1f92f8dc8cf87"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1Gd6ZnvGNbTv4Fa6185GMgQVy8H2zW4p8X",
         "value":25250,
         "n":7,
         "script":"76a914ab5d81d2b52010049d6b535620ac15824bd9118488ac"
      },
      {
         "spent":true,
         "tx_index":157308517,
         "type":0,
         "addr":"336Ka4riKSN4ZaNGNW7hBZ6Cu2NHxUEKoj",
         "value":1168789,
         "n":8,
         "script":"a9140f606c810438483741114224ab25bd9e17e13c0387"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1C6V1DQRKK26PEK4Wrm59ZKQwhbLXMn4CY",
         "value":2000000,
         "n":9,
         "script":"76a91479b2d6f8a271f61ce1c194870b5eaeb5e6f7634d88ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"14Q2YoUEghxZaUjJYj2TS8a3NreiNzt244",
         "value":10000,
         "n":10,
         "script":"76a91425433ca723e0d6d15b1896b6d31797779a8a385c88ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1Bf6AhEaTc26caoGjjmWxKkH5QCUQzQrVG",
         "value":18500,
         "n":11,
         "script":"76a91474e560b058fc01164565ae2384c4ee056f5ce81088ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1411ESd2VkUnT7ygUVABHaqp8gbH4pCQJP",
         "value":25500,
         "n":12,
         "script":"76a91420e892209aa10e6c82ebd43ed30fb7c8fa1cb7ce88ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1HdLYf4tGqWJ6fVRhpPrq24BFVfDdYtkXb",
         "value":30000,
         "n":13,
         "script":"76a914b6614d9cf0d7268d055102b452bc36f33931ebf288ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1LrkXYMx9aAB4MkaipRTeXnoFaRPbyvFhh",
         "value":100000,
         "n":14,
         "script":"76a914d9d31b2da5e1aff1bb833cd91eb7b2091ee4431888ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"14xrjVBPdYFXvm7igUJNRWafWFBDcYFAN6",
         "value":5750,
         "n":15,
         "script":"76a9142b78c515b1b249663d626f755bb8970f4c5695b888ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1N4Et8XGo6pDkvppgR1a6tC6arerrn2exN",
         "value":16500,
         "n":16,
         "script":"76a914e6f77a21a7c7b10f96e3efbef8fa297a0a7b35f388ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"19v3yLt5QuZ425PtELjs1tTzPiDP32kHiY",
         "value":6406,
         "n":17,
         "script":"76a91461c9885ce4cf736d2ae15ce2d60460123b5955bb88ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"12ZUxv6C321n5konFPkwXbZx3eRWePiwUD",
         "value":32000,
         "n":18,
         "script":"76a914111cc79fb51f055a1ea909685272a78dcd591ef588ac"
      },
      {
         "spent":false,
         "tx_index":157308517,
         "type":0,
         "addr":"1Er6HAgYPQYZCfT9xW8f1TVrHuz6qLbDzp",
         "value":5500,
         "n":19,
         "script":"76a91497e26c7d50165834f852d3e804d43fc519765f6288ac"
      }
   ],
   "lock_time":0,
   "size":983,
   "double_spend":false,
   "time":1466847788,
   "tx_index":157308517,
   "vin_sz":1,
   "hash":"a4a8365b74cf304f23f092094187bbcbf44e80f6a7a56532bd5ea6a444220740",
   "vout_sz":20
}
  • 写回答

2条回答 默认 最新

  • dqxafj6830 2016-06-25 13:43
    关注

    Element prev_out is nested inside another element. Access it like this:

    print_r($obj['inputs'][0]['prev_out']['addr']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何证明高斯噪声的包络公式
  • ¥150 寻找王者荣耀开发作者,合作或者解答
  • ¥15 乳腺癌数据集 相关矩阵 特征选择
  • ¥15 我的游戏账号被盗取,请问我该怎么做
  • ¥15 通关usb3.0.push文件,导致usb频繁断连
  • ¥15 有没有能解决微信公众号,只能实时拍照,没有选择相册上传功能,我不懂任何技术,,有没有给我发个软件就能搞定的方法
  • ¥15 Pythontxt文本可视化
  • ¥15 如何基于Ryu环境下使用scapy包进行数据包构造
  • ¥15 springboot国际化
  • ¥15 搭建QEMU环境运行OP-TEE出现错误