Author

Topic: blockchain.info api outputting 'invalid' json (Read 2378 times)

hero member
Activity: 812
Merit: 1000
January 28, 2013, 05:07:51 PM
#5
This error should be fixed now.

thanks!
hero member
Activity: 910
Merit: 1005
This error should be fixed now.
hero member
Activity: 812
Merit: 1000
ben, is this something you could possibly change in blockchain.info's output?

Yes this can be fixed fairly easily. I just need to know which exact API call is the invalid JSON coming from?

thanks, it's from the address_balance url:

Getting the balance of an address
Retreive the balance of a bitcoin address. Querying the balance of an address by label is depreciated.

https://blockchain.info/merchant/$guid/address_balance?password=$main_password&address=$address&confirmations=$confirmations
hero member
Activity: 910
Merit: 1005
ben, is this something you could possibly change in blockchain.info's output?

Yes this can be fixed fairly easily. I just need to know which exact API call is the invalid JSON coming from?
hero member
Activity: 812
Merit: 1000
consider the following output from blockchain.info's api:

Quote
{"balance":100500000,"address":1HBaNtmXhWSvrud63SRnCoeqcX5ovjXJRu,"total_received":100500000}

this is causing my code to hug trees* on this line:

Code:
$blah = json_decode($response);

...because the address string is not being presented as a string (in quotes).

putting the above JSON into http://jsonlint.com yields the following message:

Quote from: jsonlint.com
Parse error on line 3:
...000,    "address": 1HBaNtmXhWSvrud63SRn
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

i can create a work-around myself by manually putting quotes around anything that looks like an address, before decoding, but it'd be a bit dodgey...

...anyone else encountered this issue? what did you do about it?

ben, is this something you could possibly change in blockchain.info's output?

cheers.


*quit being a productive member of society
Jump to: