Tabnine Logo
JsonValue.asDouble
Code IndexAdd Tabnine to your IDE (free)

How to use
asDouble
method
in
org.hjson.JsonValue

Best Java code snippets using org.hjson.JsonValue.asDouble (Showing top 8 results out of 315)

origin: org.hjson/hjson

 public String stringify(JsonValue value)
 {
  if (!value.isNumber()) return null;
  double val=value.asDouble();
  if (val==Double.POSITIVE_INFINITY) return "Inf";
  else if (val==Double.NEGATIVE_INFINITY) return "-Inf";
  else if (Double.isNaN(val)) return "NaN";
  else if (val==0.0 && 1/val==Double.NEGATIVE_INFINITY) return "-0";
  else return null;
 }
}
origin: hjson/hjson-java

 public String stringify(JsonValue value)
 {
  if (!value.isNumber()) return null;
  double val=value.asDouble();
  if (val==Double.POSITIVE_INFINITY) return "Inf";
  else if (val==Double.NEGATIVE_INFINITY) return "-Inf";
  else if (Double.isNaN(val)) return "NaN";
  else if (val==0.0 && 1/val==Double.NEGATIVE_INFINITY) return "-0";
  else return null;
 }
}
origin: hjson/hjson-java

/**
 * Returns the <code>double</code> value of the member with the specified name in this object. If
 * this object does not contain a member with this name, the given default value is returned. If
 * this object contains multiple members with the given name, the last one will be picked. If this
 * member's value does not represent a JSON number or if it cannot be interpreted as Java
 * <code>double</code>, an exception is thrown.
 *
 * @param name
 *          the name of the member whose value is to be returned
 * @param defaultValue
 *          the value to be returned if the requested member is missing
 * @return the value of the last member with the specified name, or the given default value if
 *         this object does not contain a member with that name
 */
public double getDouble(String name, double defaultValue) {
 JsonValue value=get(name);
 return value!=null ? value.asDouble() : defaultValue;
}
origin: org.hjson/hjson

/**
 * Returns the <code>double</code> value of the member with the specified name in this object. If
 * this object does not contain a member with this name, the given default value is returned. If
 * this object contains multiple members with the given name, the last one will be picked. If this
 * member's value does not represent a JSON number or if it cannot be interpreted as Java
 * <code>double</code>, an exception is thrown.
 *
 * @param name
 *          the name of the member whose value is to be returned
 * @param defaultValue
 *          the value to be returned if the requested member is missing
 * @return the value of the last member with the specified name, or the given default value if
 *         this object does not contain a member with that name
 */
public double getDouble(String name, double defaultValue) {
 JsonValue value=get(name);
 return value!=null ? value.asDouble() : defaultValue;
}
origin: org.hjson/hjson

 public String stringify(JsonValue value)
 {
  if (stringify && value.isNumber() && value.asLong()==value.asDouble())
  {
   return "0x"+Long.toHexString(value.asLong());
  }
  else
  {
   return null;
  }
 }
}
origin: hjson/hjson-java

 public String stringify(JsonValue value)
 {
  if (stringify && value.isNumber() && value.asLong()==value.asDouble())
  {
   return "0x"+Long.toHexString(value.asLong());
  }
  else
  {
   return null;
  }
 }
}
origin: net.akehurst.application.framework/net.akehurst.application.framework.technology.persistence.filesystem

Object convertJsonToJava(final JsonValue value) throws PersistentStoreException {
  if (null == value) {
    return null;
  } else if (value.isString()) {
    return value.asString();
  } else if (value.isNumber()) {
    return value.asDouble();
  } else if (value.isBoolean()) {
    return value.asBoolean();
  } else if (value.isArray()) {
    final List<Object> list = new ArrayList<>();
    for (final JsonValue av : value.asArray()) {
      final Object o = this.convertJsonToJava(av);
      list.add(o);
    }
    return list;
  } else if (value.isObject()) {
    final Map<String, Object> map = new HashMap<>();
    for (final String k : value.asObject().names()) {
      final JsonValue jv = value.asObject().get(k);
      final Object v = this.convertJsonToJava(jv);
      map.put(k, v);
    }
    return map;
  } else {
    throw new PersistentStoreException("Unknown JSON type.", null);
  }
}
origin: net.akehurst.application.framework/net.akehurst.application.framework.technology.persistence.filesystem

  return t;
} else if (value.isNumber()) {
  final T t = this.af.createDatatype(itemType, value.asDouble());
  return t;
} else if (value.isBoolean()) {
org.hjsonJsonValueasDouble

Javadoc

Returns this JSON value as a double value, assuming that this value represents a JSON number. If this is not the case, an exception is thrown.

If the JSON number is out of the Double range, Double#POSITIVE_INFINITY or Double#NEGATIVE_INFINITY is returned.

Popular methods of JsonValue

  • toString
    Returns the JSON/Hjson string for this value using the given formatting.
  • readHjson
    Reads a Hjson value from the given string.
  • asObject
    Returns this JSON value as JsonObject, assuming that this value represents a JSON object. If this is
  • asString
    Returns this JSON value as String, assuming that this value represents a JSON string. If this is not
  • asArray
    Returns this JSON value as JsonArray, assuming that this value represents a JSON array. If this is n
  • asBoolean
    Returns this JSON value as a boolean value, assuming that this value is either true or false. If thi
  • isNumber
    Detects whether this value represents a JSON number.
  • writeTo
    Writes the JSON/Hjson representation of this value to the given writer using the given formatting. W
  • equals
    Indicates whether some other object is "equal to" this one according to the contract specified in Ob
  • hashCode
  • readJSON
    Reads a JSON value from the given string.
  • asFloat
    Returns this JSON value as a float value, assuming that this value represents a JSON number. If this
  • readJSON,
  • asFloat,
  • asInt,
  • asLong,
  • getType,
  • isBoolean,
  • isObject,
  • isPunctuatorChar,
  • isString

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Collectors (java.util.stream)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now