/** * Construct a JSONArray from a collection of beans. * The collection should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Collection collection, boolean includeSuperClass) { this.myArrayList = new ArrayList(); if (collection != null) { Iterator iter = collection.iterator();; while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Map) { this.myArrayList.add(new JSONObject((Map)o, includeSuperClass)); } else if (!JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(new JSONObject(o, includeSuperClass)); } else { this.myArrayList.add(o); } } } }
/** * Construct a JSONArray from a collection of beans. * The collection should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Collection collection, boolean includeSuperClass) { this.myArrayList = new ArrayList(); if (collection != null) { Iterator iter = collection.iterator();; while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Map) { this.myArrayList.add(new JSONObject((Map)o, includeSuperClass)); } else if (!JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(new JSONObject(o, includeSuperClass)); } else { this.myArrayList.add(o); } } } }
/** * Construct a JSONArray from a collection of beans. * The collection should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Collection collection, boolean includeSuperClass) { this.myArrayList = new ArrayList(); if (collection != null) { Iterator iter = collection.iterator();; while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Map || !JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(new JSONObject((Map)o, includeSuperClass)); } else { this.myArrayList.add(o); } } } }
/** * Construct a JSONObject from a Map. * * Note: Use this constructor when the map contains <key,bean>. * * @param map - A map with Key-Bean data. * @param includeSuperClass - Tell whether to include the super class properties. */ public JSONObject(Map map, boolean includeSuperClass) { this.map = new HashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry) i.next(); if (isStandardProperty(e.getValue().getClass())) { this.map.put(e.getKey(), e.getValue()); } else { this.map.put(e.getKey(), new JSONObject(e.getValue(), includeSuperClass)); } } } }
/** * Construct a JSONArray from an array with a bean. * The array should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Object array,boolean includeSuperClass) throws JSONException { this(); if (array.getClass().isArray()) { int length = Array.getLength(array); for (int i = 0; i < length; i += 1) { Object o = Array.get(array, i); if (JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(o); } else { this.myArrayList.add(new JSONObject(o,includeSuperClass)); } } } else { throw new JSONException("JSONArray initial value should be a string or collection or array."); } }
/** * Construct a JSONObject from a Map. * * Note: Use this constructor when the map contains <key,bean>. * * @param map - A map with Key-Bean data. * @param includeSuperClass - Tell whether to include the super class properties. */ public JSONObject(Map map, boolean includeSuperClass) { this.map = new HashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry)i.next(); if (isStandardProperty(e.getValue().getClass())) { this.map.put(e.getKey(), e.getValue()); } else { this.map.put(e.getKey(), new JSONObject(e.getValue(), includeSuperClass)); } } } }
/** * Construct a JSONObject from a Map. * * Note: Use this constructor when the map contains <key,bean>. * * @param map - A map with Key-Bean data. * @param includeSuperClass - Tell whether to include the super class properties. */ public JSONObject(Map map, boolean includeSuperClass) { this.map = new HashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry)i.next(); if (isStandardProperty(e.getValue().getClass())) { this.map.put(e.getKey(), e.getValue()); } else { this.map.put(e.getKey(), new JSONObject(e.getValue(), includeSuperClass)); } } } }
/** * Construct a JSONArray from an array with a bean. * The array should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Object array,boolean includeSuperClass) throws JSONException { this(); if (array.getClass().isArray()) { int length = Array.getLength(array); for (int i = 0; i < length; i += 1) { Object o = Array.get(array, i); if (JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(o); } else { this.myArrayList.add(new JSONObject(o,includeSuperClass)); } } } else { throw new JSONException("JSONArray initial value should be a string or collection or array."); } }
/** * Construct a JSONArray from an array with a bean. * The array should have Java Beans. * * @throws JSONException If not an array. */ public JSONArray(Object array,boolean includeSuperClass) throws JSONException { this(); if (array.getClass().isArray()) { int length = Array.getLength(array); for (int i = 0; i < length; i += 1) { Object o = Array.get(array, i); if (JSONObject.isStandardProperty(o.getClass())) { this.myArrayList.add(o); } else { this.myArrayList.add(new JSONObject(o,includeSuperClass)); } } } else { throw new JSONException("JSONArray initial value should be a string or collection or array."); } }
}else if (result instanceof Map) { map.put(key, new JSONObject((Map)result,includeSuperClass)); }else if (isStandardProperty(result.getClass())) { //Primitives, String and Wrapper map.put(key, result); }else{
} else if (result instanceof Map) { map.put(key, new JSONObject((Map) result, includeSuperClass)); } else if (isStandardProperty(result.getClass())) { // Primitives, String and Wrapper map.put(key, result); } else {
}else if (result instanceof Map) { map.put(key, new JSONObject((Map)result,includeSuperClass)); }else if (isStandardProperty(result.getClass())) { //Primitives, String and Wrapper map.put(key, result); }else{
}else if (result instanceof Map) { map.put(key, new JSONObject((Map)result,includeSuperClass)); }else if (isStandardProperty(result.getClass())) { //Primitives, String and Wrapper map.put(key, result); }else{
} else if (result instanceof Map) { map.put(key, new JSONObject((Map)result, includeSuperClass)); } else if (isStandardProperty(result.getClass())) { // Primitives, String and Wrapper map.put(key, result); } else {
} else if (result instanceof Map) { map.put(key, new JSONObject((Map)result, includeSuperClass)); } else if (isStandardProperty(result.getClass())) { // Primitives, String and Wrapper map.put(key, result); } else {