/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. * @throws JSONException On internal errors. Shouldn't happen. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
return numberToString((Number) value);
new JSONArray(value).write(writer, indentFactor, indent); } else if (value instanceof Number) { writer.write(numberToString((Number) value)); } else if (value instanceof Boolean) { writer.write(value.toString());
out.append(JSONObject.numberToString((Number) value));
out.append(JSONObject.numberToString((Number) value));
final String numberAsString = numberToString((Number) value); try {
} else if (value instanceof Number) { final String numberAsString = numberToString((Number) value); try {
} else if (value instanceof Number) { final String numberAsString = numberToString((Number) value); if(NUMBER_PATTERN.matcher(numberAsString).matches()) { writer.write(numberAsString);
final String numberAsString = JSONObject.numberToString((Number) value); if(JSONObject.NUMBER_PATTERN.matcher(numberAsString).matches()) {
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public JSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); out.append(JSONObject.numberToString(value)); return this; }
/** * Make a string from the contents of this JSONArray. The separator string * is inserted between each element. * Warning: This method assumes that the data structure is acyclical. * @param separator A string that will be inserted between the elements. * @return a string. */ public String join(String separator) { int i; Object o; StringBuffer sb = new StringBuffer(); for (i = 0; i < myArrayList.size(); i += 1) { if (i > 0) { sb.append(separator); } o = myArrayList.get(i); if (o == null) { sb.append("null"); } else if (o instanceof String) { sb.append(JSONObject.quote((String)o)); } else if (o instanceof Number) { sb.append(JSONObject.numberToString((Number)o)); } else { sb.append(o.toString()); } } return sb.toString(); }
private static String wrapArgument(final Object o) { if (o == null || o.equals(JSONObject.NULL)) { return JSONObject.NULL.toString(); } if (o instanceof JSONArray || o instanceof JSONObject || o instanceof Boolean) { return o.toString(); } try { if (o instanceof Collection) { return new JSONArray((Collection) o).toString(); } else if (o.getClass().isArray()) { return new JSONArray(o).toString(); } if (o instanceof Map) { return new JSONObject((Map) o).toString(); } if (o instanceof Number) { return JSONObject.numberToString((Number) o); } if (o instanceof Character || o instanceof CharSequence) { return JSONObject.quote(String.valueOf(o)); } if (o.getClass().getPackage().getName().startsWith("java.")) { return JSONObject.quote(o.toString()); } } catch (final Exception ignored) { } return JSONObject.NULL.toString(); }
/** * Encodes {@code value} to this stringer. * * @param value a finite value. May not be {@link Double#isNaN() NaNs} or * {@link Double#isInfinite() infinities}. * @return this stringer. */ public MyJSONStringer value(double value) throws JSONException { if (stack.isEmpty()) { throw new JSONException("Nesting problem"); } beforeValue(); stringBuilder.append(getColoredString(JSONObject.numberToString(value), COLOR_ATOM)); return this; }
out.append(JSONObject.numberToString((Number) value));
out.append(JSONObject.numberToString((Number) value));