Ejemplo n.º 1
0
 public Map getEnv() {
   if (env == null) {
     // parse env
     String _env = request.getParameter("env");
     if (_env != null && _env.length() > 0 && _env.startsWith("{")) {
       env = JsonUtil.toMap(_env);
     }
   }
   return env;
 }
 /** Constructor, parses from a JSON response String. */
 public ReadResponse(InternalResponse resp) {
   super(resp);
   try {
     JSONObject rootJsonObj = new JSONObject(resp.getContent());
     Response.withMeta(this, rootJsonObj);
     JSONObject respJson = rootJsonObj.getJSONObject(Constants.RESPONSE);
     Object dataObj = respJson.get(Constants.QUERY_DATA);
     if (dataObj instanceof JSONArray) {
       data = JsonUtil.data(respJson.getJSONArray(Constants.QUERY_DATA));
     } else if (dataObj instanceof JSONObject) {
       data.add(JsonUtil.toMap((JSONObject) dataObj));
     }
   } catch (JSONException e) {
     throw new RuntimeException(e);
   }
 }