Bitcoin Forum

Economy => Service Discussion => Topic started by: gatomalo on November 05, 2014, 02:51:09 PM



Title: How do I extract the JSON balance data from this chain.com API call
Post by: gatomalo on November 05, 2014, 02:51:09 PM
I'm new to PHP and I need help. I have a test wallet - and I want to extract the balance data from this API call from chain.com

{"hash":"16sxw3dFK4aq8WH8gzWDW8XjyutJojsKJG","balance":346929,"received":346929,"sent":0,"unconfirmed_received":0,"unconfirmed_sent":0,"unconfirmed_balance":0}

With PHP is there an easy way to parse this out? I tried the object class route but failed-

object(stdClass)#1 (7) {
  ["hash"]=>
  string(34) "16sxw3dFK4aq8WH8gzWDW8XjyutJojsKJG"
  ["balance"]=>
  int(346929)
  ["received"]=>
  int(346929)
  ["sent"]=>
  int(0)
  ["unconfirmed_received"]=>
  int(0)
  ["unconfirmed_sent"]=>
  int(0)
  ["unconfirmed_balance"]=>
  int(0)
}

Any help would be welcomed.


Title: Re: How do I extract the JSON balance data from this chain.com API call
Post by: henry4 on November 13, 2014, 05:12:51 PM

If you have a lot of JSON data that you just want to process once-only - you can use https://json-csv.com (https://json-csv.com) to convert it to a CSV file - then if you open the file up in a spreadsheet the balance will all be in the same column.