private static Map<String, Object> jsonToMap(JSONObject json, Expressions expressions, ELContext context) { Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : JSONObject.getNames(json)) { Object val = jsonToConfig(json.opt(key), expressions, context); if (val != null) { values.put(key, val); } } return Collections.unmodifiableMap(values); }
private static Map<String, Object> jsonToMap(JSONObject json, Expressions expressions, ELContext context) { Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : JSONObject.getNames(json)) { Object val = jsonToConfig(json.opt(key), expressions, context); if (val != null) { values.put(key, val); } } return Collections.unmodifiableMap(values); }
/** * Convert a JSON value to a configuration value. */ private static Object jsonToConfig(Object json, Expressions expressions, ELContext context) { if (JSONObject.NULL.equals(json)) { return null; } else if (json instanceof CharSequence) { return new DynamicConfigProperty(json.toString(), expressions, context); } else if (json instanceof JSONArray) { JSONArray jsonArray = (JSONArray) json; List<Object> values = new ArrayList<Object>(jsonArray.length()); for (int i = 0, j = jsonArray.length(); i < j; ++i) { values.add(jsonToConfig(jsonArray.opt(i), expressions, context)); } return Collections.unmodifiableList(values); } else if (json instanceof JSONObject) { return jsonToMap((JSONObject) json, expressions, context); } // A (boxed) primitive. return json; }
/** * Convert a JSON value to a configuration value. */ private static Object jsonToConfig(Object json, Expressions expressions, ELContext context) { if (JSONObject.NULL.equals(json)) { return null; } else if (json instanceof CharSequence) { return new DynamicConfigProperty(json.toString(), expressions, context); } else if (json instanceof JSONArray) { JSONArray jsonArray = (JSONArray) json; List<Object> values = new ArrayList<Object>(jsonArray.length()); for (int i = 0, j = jsonArray.length(); i < j; ++i) { values.add(jsonToConfig(jsonArray.opt(i), expressions, context)); } return Collections.unmodifiableList(values); } else if (json instanceof JSONObject) { return jsonToMap((JSONObject) json, expressions, context); } // A (boxed) primitive. return json; }