org.json.JSONObject.numberToString()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中org.json.JSONObject.numberToString()方法的一些代码示例,展示了JSONObject.numberToString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.numberToString()方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:numberToString

JSONObject.numberToString介绍

[英]Encodes the number as a JSON string.
[中]将数字编码为JSON字符串。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * 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;
}

代码示例来源:origin: apache/geode

/**
 * 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;
}

代码示例来源:origin: zzz40500/GsonFormat

return numberToString((Number) value);

代码示例来源:origin: zzz40500/GsonFormat

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());

代码示例来源:origin: apache/geode

out.append(JSONObject.numberToString((Number) value));

代码示例来源:origin: robovm/robovm

out.append(JSONObject.numberToString((Number) value));

代码示例来源:origin: loklak/loklak_server

final String numberAsString = numberToString((Number) value);
try {

代码示例来源:origin: loklak/loklak_server

} else if (value instanceof Number) {
  final String numberAsString = numberToString((Number) value);
  try {

代码示例来源:origin: b3log/latke

} else if (value instanceof Number) {
  final String numberAsString = numberToString((Number) value);
  if(NUMBER_PATTERN.matcher(numberAsString).matches()) {
    writer.write(numberAsString);

代码示例来源:origin: b3log/latke

final String numberAsString = JSONObject.numberToString((Number) value);
if(JSONObject.NUMBER_PATTERN.matcher(numberAsString).matches()) {

代码示例来源:origin: MobiVM/robovm

/**
 * 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;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * 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;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * 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;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * 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;
}

代码示例来源:origin: com.vaadin.external.google/android-json

/**
 * 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;
}

代码示例来源:origin: com.metaparadigm/json-rpc

/**
 * 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();
}

代码示例来源:origin: com.sdklite/sphere-hybrid-spi

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();
}

代码示例来源:origin: MuShare/Httper-Android

/**
 * 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;
}

代码示例来源:origin: com.gluonhq/robovm-rt

out.append(JSONObject.numberToString((Number) value));

代码示例来源:origin: com.vaadin.external.google/android-json

out.append(JSONObject.numberToString((Number) value));

相关文章

JSONObject类方法