code: public static JsonObject getJsonQuery(URL url) throws MalformedURLException {
          String query = url.getQuery();
          JsonObject payload = new JsonObject();
          JsonParser parser = new JsonParser();
  
          if (query == null) {
              return null;
          }
  
          for (String kv : query.split("&")) {
              String[] parts = kv.split("=");
  
              if (parts.length != 2) {
                  throw new MalformedURLException();
              }
  
              String optName = parts[0];
              JsonElement optVal;
              try {
                  optVal = parser.parse(URLDecoder.decode(parts[1], "UTF-8"));
              } catch (UnsupportedEncodingException e) {
                  throw new MalformedURLException();
              }
  
              payload.add(optName, optVal);
          }
          return payload;
      }
docs: Parses a url-encoded query string and
  @param url The URL to decode
  @return a map of keys and JSON Values
  @throws MalformedURLException If one of the values is not JSON