Issue with ArduinoJson6 and httpclient on ESP8266


Im playing around with a basic api query for the balance of a random bitcoin address. I had it working with arduinojson5 but i could not get it to convert the balance to an int to do some calculations against it (convert from satoshis to btc)

The current code I have just reports a zero. My plan was to get it to output to the Oled once I had it working via the serial monitor, code below. Any tips greatly appreciated.

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>

const char* ssid = “REDACTED”;
const char* password = “REDACTED?”;

void setup()
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED)

void loop()
if (WiFi.status() == WL_CONNECTED)
HTTPClient http; //Object of class HTTPClient
int httpCode = http.GET();

if (httpCode > 0)
const size_t capacity = JSON_OBJECT_SIZE(9) + 160;
DynamicJsonDocument doc(capacity);
//JsonObject& root = doc.parseObject(http.getString());

//const char* json = http.getString();

deserializeJson(doc, http.getString());

const char* address = doc[“address”]; // “1Hz96kJKF2HLPGY15JWLB5m9qGNxvt8tHJ”
long total_received = doc[“total_received”]; // 17712591964335
long total_sent = doc[“total_sent”]; // 17682499192049
long balance = doc[“balance”]; // 30092772286
int unconfirmed_balance = doc[“unconfirmed_balance”]; // 0
long final_balance = doc[“final_balance”]; // 30092772286
int n_tx = doc[“n_tx”]; // 14358
int unconfirmed_n_tx = doc[“unconfirmed_n_tx”]; // 0
int final_n_tx = doc[“final_n_tx”]; // 14358

//int id = root[“id”];
//const char* final_balance = root[“final_balance”];
//float balance = final_balance / 100000000;
//int balance = doc[“final_balance”];

Serial.print(“Sat Balance:”);
//Serial.print("/nSat Balance:");

http.end(); //Close connection

it’s not my BTC address, just the first one I found

If I run this:

String payload = http.getString(); Serial.println(payload);

It shows the json as a string and all looks correct. So it's not an issue with connectivity or getting the data from the site. I just don't know what im doing wrong with the deserialization.