Write a JSON value.

@param value
One of these types: JSONObject, JSONArray (or Map or
Collection or array), Number (or Integer or Long or Double),
or String, or Boolean, or JSONObject.NULL, or null.
@throws JSONException
16973
@SuppressWarnings({ "rawtypes", "unchecked" })
    private void writeJSON(Object value) throws JSONException {
        if (JSONObject.NULL.equals(value)) {
            write(zipNull, 3);
        } else if (Boolean.FALSE.equals(value)) {
            write(zipFalse, 3);
        } else if (Boolean.TRUE.equals(value)) {
            write(zipTrue, 3);
        } else {
            if (value instanceof Map) {
                value = new JSONObject((Map) value);
            } else if (value instanceof Collection) {
                value = new JSONArray((Collection) value);
            } else if (value.getClass().isArray()) {
                value = new JSONArray(value);
            }
            if (value instanceof JSONObject) {
                write((JSONObject) value);
            } else if (value instanceof JSONArray) {
                write((JSONArray) value);
            } else {
                throw new JSONException("Unrecognized object");
            }
        }
    }
1162724
public void writeValue (String name, Object value) {
		try {
			writer.name(name);
		} catch (IOException ex) {
			throw new JsonException(ex);
		}
		if (value == null)
			writeValue(value, null, null);
		else
			writeValue(value, value.getClass(), null);
	}
1289881
public static void serialize(Value value, Writer writer) throws JSONException {
		Serializer.serialize(value, writer);
	}
1318865
void write(Object value) throws IOException {
    if (clientInputSerializer != null) {
      clientInputSerializer.serialize(value);
      return;
    }

    byte[] bval;
    int valSize;
    if (value instanceof BytesWritable) {
      BytesWritable val = (BytesWritable) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else if (value instanceof Text) {
      Text val = (Text) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else {
      String sval = value.toString();
      bval = sval.getBytes("UTF-8");
      valSize = bval.length;
    }
    clientOut_.write(bval, 0, valSize);
  }
1371231
public JsonObject put(String name, double value) throws JsonException {
        return put(name, new JsonNumber(value));
    }
627453
@Override
    protected void write(JsonGenerator g, JacksonJrsTreeCodec codec) throws IOException
    {
        switch (numberType()) {
        case INT:
            g.writeNumber(_value.intValue());
            break;
        case LONG:
            g.writeNumber(_value.longValue());
            break;
        case BIG_INTEGER:
            g.writeNumber((BigInteger) _value);
            break;
        case FLOAT:
            g.writeNumber(_value.floatValue());
            break;
        case BIG_DECIMAL:
            g.writeNumber((BigDecimal) _value);
            break;
        case DOUBLE:
        default:
            g.writeNumber(_value.doubleValue());
            break;
        }
    }
1139904
private JsonElement toElement(final Object value) {

		if (value != null) {

			if (value instanceof String) {

				return new JsonPrimitive((String)value);

			} else if (value instanceof Number) {

				return new JsonPrimitive((Number)value);

			} else if (value instanceof Boolean) {

				return new JsonPrimitive((Boolean)value);

			} else if (value.getClass().isArray()) {

				final JsonArray arr   = new JsonArray();
				final Object[] values = (Object[])value;

				for (final Object v : values) {
					arr.add(toElement(v));
				}

				return arr;

			} else {

				return new JsonPrimitive(value.toString());
			}
		}

		return JsonNull.INSTANCE;
	}
1065742
public JsonWriter value(CharSequence value) {
        startValue();

        if (value == null) {
            writer.write(kNull);
        } else {
            writeQuotedAndEscaped(value);
        }
        return this;
    }
362450
public JSONStringer value(boolean value) throws JSONException {
		if (this.stack.isEmpty()) {
			throw new JSONException("Nesting problem");
		}
		beforeValue();
		this.out.append(value);
		return this;
	}
269532
public JsonWriter value(boolean value) {
    try {
      stream.value(value);
      return this;
    } catch (Exception e) {
      throw rethrow(e);
    }
  }
30850
public JsonWriter value(Boolean value) throws IOException {
    if (value == null) {
      return nullValue();
    }
    writeDeferredName();
    beforeValue();
    out.write(value ? "true" : "false");
    return this;
  }
403970
public JsonWriter value(@NonNull Iterable<?> value) throws IOException {
      Preconditions.checkArgument(inArray() || writeStack.peek() == JsonTokenType.NAME,
                                  "Expecting an array or a name, but found " + writeStack.peek());
      popIf(JsonTokenType.NAME);
      beginArray();
      for (Object o : value) {
         value(o);
      }
      endArray();
      return this;
   }
567355
public void writeValue(Object value) throws IOException
    {
        if (value == null) {
            writeNullValue();
            return;
        }
        _writeValue(value, _writerLocator.findSerializationType(value.getClass()));
    }
293082
public Writer write(Writer writer) throws JSONException {
    try {
      boolean b = false;
      int len = length();

      writer.write('[');

      for (int i = 0; i < len; i += 1) {
        if (b) {
          writer.write(',');
        }
        Object v = this.myArrayList.get(i);
        if (v instanceof JSONObject) {
          ((JSONObject) v).write(writer);
        } else if (v instanceof JSONArray) {
          ((JSONArray) v).write(writer);
        } else {
          writer.write(JSONObject.valueToString(v));
        }
        b = true;
      }
      writer.write(']');
      return writer;
    } catch (IOException e) {
      throw new JSONException(e);
    }
  }
1222082
public JsonArray add(Object value) {
        if (value == this) {
            throw new IllegalArgumentException("Cannot add self");
        } else if (value == JsonValue.NULL) {
            addNull();
        } else if (checkType(value)) {
            content.add(value);
        } else {
            throw new IllegalArgumentException("Unsupported type for JsonArray: " + value.getClass());
        }
        return this;
    }
896958
@Override
  public void write(JsonWriterImpl out, T value)
  {
    if (value == null) {
      out.writeNull();
    }
    else if (value.getClass() != Object.class) {
      out.writeObjectValue(value);
    }
  }
659698
public static JsonValue value(double value) {
    if (Double.isInfinite(value) || Double.isNaN(value)) {
      throw new IllegalArgumentException(INFINITE_AND_NAN);
    }
    return new JsonNumber(cutOffPointZero(Double.toString(value)));
  }