@Override public Object createObject() { return new JsonObject(); }
/** * Returns true if the object has a number element at that key. */ public boolean isNumber(String key) { return get(key) instanceof Number; }
/** * Returns the {@link JsonArray} at the given key, or null if it does not exist or is the wrong * type. */ public Json.Array getArray(String key) { return getArray(key, (Json.Array) null); }
return token = Token.COLON; case '{': // Inlined function to avoid additional stack JsonObject map = new JsonObject(); if (advanceToken() != Token.OBJECT_END) while (true) { throw createParseException(null, "Expected COLON, got " + token, true); advanceToken(); map.put(key, currentValue()); if (advanceToken() == Token.OBJECT_END) break;
/** * Returns the {@link Long} at the given key, or 0 if it does not exist or is the wrong type. */ public long getLong(String key) { return getLong(key, 0L); }
/** * Returns the {@link JsonObject} at the given key, or null if it does not exist or is the wrong * type. */ public Json.Object getObject(String key) { return getObject(key, null); }
/** * Returns the {@link String} at the given key, or null if it does not exist or is the wrong type. */ public String getString(String key) { return getString(key, null); }
/** * Returns the {@link Double} at the given key, or 0.0 if it does not exist or is the wrong type. */ public double getDouble(String key) { return getDouble(key, 0); }
/** * Returns the {@link Boolean} at the given key, or false if it does not exist or is the wrong * type. */ public boolean getBoolean(String key) { return getBoolean(key, false); }
/** * Returns the {@link Integer} at the given key, or 0 if it does not exist or is the wrong type. */ public int getInt(String key) { return getInt(key, 0); }
/** * Returns the {@link Float} at the given key, or 0.0f if it does not exist or is the wrong type. */ public float getNumber(String key) { return getNumber(key, 0); }
return token = Token.COLON; case '{': // Inlined function to avoid additional stack JsonObject map = new JsonObject(); if (advanceToken() != Token.OBJECT_END) while (true) { throw createParseException(null, "Expected COLON, got " + token, true); advanceToken(); map.put(key, currentValue()); if (advanceToken() == Token.OBJECT_END) break;
/** * Returns the {@link Long} at the given key, or 0 if it does not exist or is the wrong type. */ public long getLong(String key) { return getLong(key, 0L); }
/** * Returns the {@link JsonObject} at the given key, or null if it does not exist or is the wrong * type. */ public Json.Object getObject(String key) { return getObject(key, null); }
/** * Returns the {@link String} at the given key, or null if it does not exist or is the wrong type. */ public String getString(String key) { return getString(key, null); }
/** * Returns the {@link Double} at the given key, or 0.0 if it does not exist or is the wrong type. */ public double getDouble(String key) { return getDouble(key, 0); }
/** * Returns the {@link Boolean} at the given key, or false if it does not exist or is the wrong * type. */ public boolean getBoolean(String key) { return getBoolean(key, false); }
/** * Returns the {@link Integer} at the given key, or 0 if it does not exist or is the wrong type. */ public int getInt(String key) { return getInt(key, 0); }
/** * Returns the {@link Float} at the given key, or 0.0f if it does not exist or is the wrong type. */ public float getNumber(String key) { return getNumber(key, 0); }
/** * Returns the {@link String} at the given key, or the default if it does not exist or is the * wrong type. */ public String getString(String key, String default_) { Object o = get(key); return (o instanceof String) ? (String)o : default_; }