Package org.ghotibeaun.json
Interface JSONValue<T>
- Type Parameters:
T
- the value type
- All Superinterfaces:
Comparable<JSONValue<T>>
,Serializable
public interface JSONValue<T> extends Serializable, Comparable<JSONValue<T>>
Interface for values stored in JSONObject or JSONArray containers
- Author:
- jearley
-
Method Summary
Modifier and Type Method Description JSONValueType
getType()
Returns the value type hintT
getValue()
Return the valueboolean
isArray()
Returns whether the value is a JSONArray instanceboolean
isEquivalent(JSONValue<?> otherValue)
default boolean
isObject()
Returns whether the value is aJSONObject
instanceboolean
isPrimitive()
Returns whether the value is a primitive data type (String, Number, Boolean, Null)String
prettyPrint()
Returns a pretty-printed JSON structureString
prettyPrint(int indent)
Pretty print using a specified indent valuevoid
setValue(T value)
Set the valueString
toString()
Methods inherited from interface java.lang.Comparable
compareTo
-
Method Details
-
getValue
T getValue()Return the value- Returns:
- the value
-
toString
String toString() -
getType
JSONValueType getType()Returns the value type hint- Returns:
- the value type hint
-
isPrimitive
boolean isPrimitive()Returns whether the value is a primitive data type (String, Number, Boolean, Null)- Returns:
- true if the value is a primitive data type
-
isArray
boolean isArray()Returns whether the value is a JSONArray instance- Returns:
- true if the value is a JSONArray
-
isObject
default boolean isObject()Returns whether the value is aJSONObject
instance- Returns:
- true if the value is a JSONObject
-
setValue
Set the value- Parameters:
value
- the value
-
prettyPrint
String prettyPrint()Returns a pretty-printed JSON structure- Returns:
- a pretty-printed JSON structure
-
prettyPrint
Pretty print using a specified indent value- Parameters:
indent
- the indent value- Returns:
- a pretty-printed JSON structure
-
isEquivalent
-