示例#1
0
  /**
   * get some JSONArray
   *
   * @param jsonStr
   * @param searchWord
   * @return
   */
  public static JSONArray getJSONArray(final Object jsonStr, final String searchWord) {

    Object res = null;

    try {
      JSONObject obj = new JSONObject((String) jsonStr);
      res = obj.get(searchWord);

      if (CommonUtil.isNull(res)) return null;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return (JSONArray) res;
  }
示例#2
0
  /**
   * get some int Array
   *
   * @param jsonStr
   * @param searchWord
   * @return
   */
  public static Integer[] getArrayInt(final Object jsonStr, final String searchWord) {

    Object res[] = null;

    try {
      JSONObject obj = new JSONObject((String) jsonStr);
      res = (Integer[]) obj.get(searchWord);

      if (CommonUtil.isNull(res)) return null;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return (Integer[]) res;
  }
示例#3
0
  /**
   * get some boolean
   *
   * @param jsonStr
   * @param searchWord
   * @return
   */
  public static boolean getBoolean(final Object jsonStr, final String searchWord) {

    Object res = null;

    try {
      JSONObject obj = new JSONObject((String) jsonStr);
      res = obj.get(searchWord);

      if (CommonUtil.isNull(res)) return false;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return (Boolean) res;
  }
示例#4
0
  /**
   * get some String
   *
   * @param jsonStr
   * @param searchWord
   * @return
   */
  public static String getString(final Object jsonStr, final String searchWord) {

    Object res = null;

    try {
      JSONObject obj = new JSONObject((String) jsonStr);
      res = obj.get(searchWord);

      if (CommonUtil.isNull(res)) return "";

    } catch (Exception e) {
      e.printStackTrace();
    }
    return String.valueOf(res);
  }