/** * 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; }
/** * 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; }
/** * 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; }
/** * 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); }