JSON Null Pointer Exception

Null pointer exception?

JSONObject unDispersed;

  Float undisperesdLTC = unDispersed.getJSONObject("data").getFloat("confirmed_balance");

void setup() {
  size(480, 320);
  frameRate(24);
}

void draw() {
  pullUndispersed();
  println(undisperesdLTC);
}

void pullUndispersed() {
    //LTC pool
  String  walletAPI_URL = "https://"+"chain.so/api/v2/get_address_balance/LTC/LNhixHYiLQF2v6wKyoiizgJaQunuy6d8Jx/6";
  unDispersed = loadJSONObject(walletAPI_URL);
}

Answers

  • edited March 2018
    1. the forum is killing links

    2. you try to use unDispersed in line 3 but it's only set in line 18, you need a new order:

    (changed http a bit to avoid that forum changes it)

    JSONObject unDispersed;
    
    Float undisperesdLTC;
    
    void setup() {
      size(480, 320);
      frameRate(24);
    
      pullUndispersed();
    }
    
    void draw() {
    
      undisperesdLTC = unDispersed.getJSONObject("data").getFloat("confirmed_balance");
    
      println(undisperesdLTC);
    }
    
    void pullUndispersed() {
    
      String  walletAPI_URL = "http : // chain.so/api/v2/get_address_balance/LTC/LNhixHYiLQF2v6wKyoiizgJaQunuy6d8Jx/6" ;
    
      unDispersed = loadJSONObject(walletAPI_URL);
    }
    

    here I receive in line 23 a http 403 - Forbidden status in response to a request from a client for a web page

    maybe reread documentation of chain.so/api

    https://en.wikipedia.org/wiki/HTTP_403

Sign In or Register to comment.