/** * Create a new array, and adds all values fro the iterable to the array (using {@link #putAll(Iterable)}. * * This is implemented as a static method so as not to break the semantics of the existing {@link #JSONArray(Object...)} constructor. * Adding a constructor of type Iterable would change the meaning of <code>new JSONArray(new JSONArray())</code>. * * @param iterable * collection ot value to include, or null * @since 5.4 */ public static JSONArray from(Iterable<?> iterable) { return new JSONArray().putAll(iterable); }
/** * Create a new array, and adds all values fro the iterable to the array (using {@link #putAll(Iterable)}. * * This is implemented as a static method so as not to break the semantics of the existing {@link #JSONArray(Object...)} constructor. * Adding a constructor of type Iterable would change the meaning of <code>new JSONArray(new JSONArray())</code>. * * @param iterable * collection ot value to include, or null * @since 5.4 */ public static JSONArray from(Iterable<?> iterable) { return new JSONArray().putAll(iterable); }
private String convert(List<?> input) { return new JSONArray().putAll(input).toString(compactJSON); }
public void addInitialization(InitializationPriority priority, String moduleName, String functionName, JSONArray arguments) { assert priority != null; assert InternalUtils.isNonBlank(moduleName); String name = functionName == null ? moduleName : moduleName + ":" + functionName; if ((arguments == null || arguments.length() == 0)) { if (pureInits.contains(name)) { // A degenerate case is a pure init added repeatedly with different priorities. That isn't handled: // the first priority wins. return; } pureInits.add(name); InternalUtils.addToMapList(inits, priority, name); } else { JSONArray init = new JSONArray(); init.put(name); init.putAll(arguments); InternalUtils.addToMapList(inits, priority, init); } initCount++; }