title: Not a JSON Object: null
body: <p>I found a github that has an open source project, but it is broken. It tries to get the JSON off of <a href="https://api.randomuser.me/?nat=gb" rel="nofollow noreferrer">https://api.randomuser.me/?nat=gb</a></p>
  
  <p>I get the error Exception in thread "main" java.lang.IllegalStateException: Not a JSON Object: null</p>
  
  <p>When I try to change it to an array, I get the error that it isn't any array. What gives?</p>
  
  <pre><code> String json = readUrl(RANDGEN_URL);
          JsonParser jsonParser = new JsonParser();
          JsonObject firstNameObject = jsonParser.parse(json)
                  .getAsJsonObject().getAsJsonArray("results").get(0)
                  .getAsJsonObject().getAsJsonObject("name");
          String firstNameString = firstNameObject.get("first").getAsString();
  
          JsonObject lastNameObject = jsonParser.parse(json)
                  .getAsJsonObject().getAsJsonArray("results").get(0)
                  .getAsJsonObject().getAsJsonObject("name");
          String lastNameString = lastNameObject.get("last").getAsString();
  
          Random randMail = new Random();
          int setMail = randMail.nextInt(90) + 10;
          String mail = firstNameString + "." + lastNameString + "" + setMail + "@gmail.com";
  
          JsonObject usernames = jsonParser.parse(json)
                  .getAsJsonObject().getAsJsonArray("results").get(0)
                  .getAsJsonObject().getAsJsonObject("login");
          String user = usernames.get("username").getAsString();
  
          if (user.length() &gt; 12) {
              Random randNum = new Random();
              int setNum = randNum.nextInt(90) + 10;
              user = user.substring(0, Math.min(user.length(), 10)) + setNum;
          }
  </code></pre>