Returns the specified JsonValue as a List. Allows single or array
542388
private static List<JsonObject> getJsonValueAsList(JsonValue value) {
        if (value != null) {
            if (value.getValueType() == ValueType.ARRAY) {
                return value.asJsonArray().getValuesAs(JsonObject.class);

            } else if (value.getValueType() == ValueType.OBJECT) {
                List<JsonObject> ret = new ArrayList<>();
                ret.add(value.asJsonObject());

                return ret;
            }
        }
        return null;
    }
9772
def _json_convert(obj, json_options=DEFAULT_JSON_OPTIONS):
    
    if hasattr(obj, 'iteritems') or hasattr(obj, 'items'):  # PY3 support
        return SON(((k, _json_convert(v, json_options))
                    for k, v in iteritems(obj)))
    elif hasattr(obj, '__iter__') and not isinstance(obj, (text_type, bytes)):
        return list((_json_convert(v, json_options) for v in obj))
    try:
        return default(obj, json_options)
    except TypeError:
        return obj
1230831
private JSONValue toJsonStringList(Collection<? extends Object> list) {

        if (null != list) {
            JSONArray array = new JSONArray();
            for (Object o : list) {
                array.set(array.size(), new JSONString(o.toString()));
            }
            return array;
        } else {
            return null;
        }
    }
565723
public JSONValue toJson() {

        JSONObject result = new JSONObject();
        if (null != getStart()) {
            result.put(JsonKey.START, dateToJson(getStart()));
        }
        if (null != getEnd()) {
            result.put(JsonKey.END, dateToJson(getEnd()));
        }
        if (isWholeDay()) {
            result.put(JsonKey.WHOLE_DAY, JSONBoolean.getInstance(true));
        }
        JSONObject pattern = patternToJson();
        result.put(JsonKey.PATTERN, pattern);
        SortedSet<Date> exceptions = getExceptions();
        if (exceptions.size() > 0) {
            result.put(JsonKey.EXCEPTIONS, datesToJsonArray(exceptions));
        }
        switch (getEndType()) {
            case DATE:
                result.put(JsonKey.SERIES_ENDDATE, dateToJson(getSeriesEndDate()));
                break;
            case TIMES:
                result.put(JsonKey.SERIES_OCCURRENCES, new JSONString(String.valueOf(getOccurrences())));
                break;
            case SINGLE:
            default:
                break;
        }
        if (!isCurrentTillEnd()) {
            result.put(JsonKey.CURRENT_TILL_END, JSONBoolean.getInstance(false));
        }
        if (getParentSeriesId() != null) {
            result.put(JsonKey.PARENT_SERIES, new JSONString(getParentSeriesId().getStringValue()));
        }
        return result;
    }
1087148
@Nullable
    static List<Object> jsonArrayToList(@Nullable JSONArray jsonArray) {
        if (jsonArray == null) {
            return null;
        }

        List<Object> objectList = new ArrayList<>();
        for (int i = 0; i < jsonArray.length(); i++) {
            try {
                Object ob = jsonArray.get(i);
                if (ob instanceof JSONArray) {
                    objectList.add(jsonArrayToList((JSONArray) ob));
                } else if (ob instanceof JSONObject) {
                    Map<String, Object> objectMap = jsonObjectToMap((JSONObject) ob);
                    if (objectMap != null) {
                        objectList.add(objectMap);
                    }
                } else {
                    if (NULL.equals(ob)) {
                        continue;
                    }
                    objectList.add(ob);
                }
            } catch (JSONException ignored) {
                // Nothing to do in this case.
            }
        }
        return objectList;
    }
58140
public static List toList(Object o, boolean duplicate, List defaultValue) {
	try {
	    return toList(o, duplicate);
	}
	catch (PageException e) {
	    return defaultValue;
	}
    }
409873
def getlist(self, key, delimiter=',', **kwargs):
        

        value = self.get(key, **kwargs)
        if value is None: return value
        if isinstance(value, str):
            value = value.strip()
            if value.startswith('[') and value.endswith(']'):
                return self.getserialized(key)

            return [p.strip(' ') for p in value.split(delimiter)]
        #end if

        return list(value)
152005
function listToArray ( list, opts ) {
	const length = list.getLength();
	const data = [];
	for ( let i = 0; i < length; i++ ) {
		const value = getJsonValueFromSassValue(list.getValue(i), opts);
		data.push(value);
	}
	return data;
}
1200872
private static String getJsonValueAsString(JsonValue value) {
        return (value != null && value.getValueType() == ValueType.STRING) ? ((JsonString) value).getString() : null;
    }
469298
def fromJSON(value):
        
        j = json.loads(value)
        v = GPLinearUnit()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
925871
private static String jcalValueToString(JCalValue value) {
		List<JsonValue> values = value.getValues();
		if (values.size() > 1) {
			List<String> multi = value.asMulti();
			if (!multi.isEmpty()) {
				return VObjectPropertyValues.writeList(multi);
			}
		}

		if (!values.isEmpty() && values.get(0).getArray() != null) {
			List<List<String>> structured = value.asStructured();
			if (!structured.isEmpty()) {
				return VObjectPropertyValues.writeStructured(structured, true);
			}
		}

		if (values.get(0).getObject() != null) {
			ListMultimap<String, String> object = value.asObject();
			if (!object.isEmpty()) {
				return VObjectPropertyValues.writeMultimap(object.getMap());
			}
		}

		return VObjectPropertyValues.escape(value.asSingle());
	}
833880
static javax.json.JsonValue map(final JsonValue jsonValue) {
        if (jsonValue instanceof JsonArray)
            return map((JsonArray) jsonValue);
        return map((JsonObject) jsonValue);
    }
1130163
def from_raw(self, rval: RawValue, jptr: JSONPointer = "") -> Value:
        """"""
        def convert(val):
            if isinstance(val, list):
                res = ArrayValue([convert(x) for x in val])
            elif isinstance(val, dict):
                res = ObjectValue({x: convert(val[x]) for x in val})
            else:
                res = val
            return res
        return convert(rval)
559393
static boolean addListToJSON(StringBuilder sb, String name, Object[] list, boolean jsonEscapeValues, boolean isFirstField) {
        if (name == null || list == null)
            return false;

        // add comma if isFirstField == false
        if (!isFirstField)
            sb.append(",");

        sb.append("\"" + name + "\":[");
        boolean firstParm = true;
        for (Object element : list) {
            if (firstParm)
                sb.append("\"");
            else
                sb.append(",\"");
            if (element != null) {
                if (jsonEscapeValues)
                    sb.append(jsonEscape2(element.toString()));
                else
                    sb.append(element.toString());
            }
            sb.append("\"");
            firstParm = false;
        }
        sb.append("]");
        return true;
    }
1183801
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static List<Object> arrayAsList(Object value) {
		if (value instanceof List) {
			return (List<Object>) value;
		}
		List list = null;
		if (value instanceof int[]) {
			list = new ArrayList();
			int[] array = (int[]) value;
			for (int i : array) {
				list.add(i);
			}
		} else if (value instanceof short[]) {
			list = new ArrayList();
			short[] array = (short[]) value;
			for (short i : array) {
				list.add(i);
			}
		} else if (value instanceof char[]) {
			list = new ArrayList();
			char[] array = (char[]) value;
			for (char i : array) {
				list.add(i);
			}
		} else if (value instanceof byte[]) {
			list = new ArrayList();
			byte[] array = (byte[]) value;
			for (byte i : array) {
				list.add(i);
			}
		} else if (value instanceof long[]) {
			list = new ArrayList();
			long[] array = (long[]) value;
			for (long i : array) {
				list.add(i);
			}
		} else if (value instanceof double[]) {
			list = new ArrayList();
			double[] array = (double[]) value;
			for (double i : array) {
				list.add(i);
			}
		} else if (value instanceof float[]) {
			list = new ArrayList();
			float[] array = (float[]) value;
			for (float i : array) {
				list.add(i);
			}
		} else if (value instanceof boolean[]) {
			list = new ArrayList();
			boolean[] array = (boolean[]) value;
			for (boolean i : array) {
				list.add(i);
			}
		} else if (value.getClass().isArray()) {
			Object[] array = (Object[]) value;
			list = Arrays.asList(array);
		}
		return list;
	}
635680
def save_list(key, *values):
    
    return json.dumps({key: [_get_json(value) for value in values]})
307983
public static JCalValue object(ListMultimap<String, Object> value) {
		Map<String, JsonValue> object = new LinkedHashMap<String, JsonValue>();
		for (Map.Entry<String, List<Object>> entry : value) {
			String key = entry.getKey();
			List<Object> list = entry.getValue();

			JsonValue v;
			if (list.size() == 1) {
				v = new JsonValue(list.get(0));
			} else {
				List<JsonValue> array = new ArrayList<JsonValue>(list.size());
				for (Object element : list) {
					array.add(new JsonValue(element));
				}
				v = new JsonValue(array);
			}
			object.put(key, v);
		}
		return new JCalValue(new JsonValue(object));
	}