Class JsonArray
java.lang.Object
com.revetsec.json.JsonArray
- All Implemented Interfaces:
JsonValue
A JSON array: an ordered, unmodifiable list of values. Two arrays are equal when they hold equal elements in the
same order.
There is no array builder: assemble a List and pass it to fromElements(List).
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionReturns the empty JSON array.booleanfromElements(@NonNull List<? extends @NonNull JsonValue> elements) Returns a JSON array holding a snapshot ofelements, in order.Returns this array's elements, in order.inthashCode()toJson()Serializes this value as compact JSON text: no insignificant whitespace, members in insertion order, and numbers in the canonical form ofBigDecimal.toString()(1e2becomes1E+2).toString()
-
Method Details
-
emptyInstance
Returns the empty JSON array.- Returns:
- the shared empty array
- Since:
- 1.0.0
-
fromElements
Returns a JSON array holding a snapshot ofelements, in order.- Parameters:
elements- the elements; later changes to the list do not affect the array- Returns:
- the JSON array
- Throws:
NullPointerException- ifelementsor any element isnullIllegalArgumentException- if the array would nest more than 64 deep- Since:
- 1.0.0
-
getElements
Returns this array's elements, in order.- Returns:
- an unmodifiable list
- Since:
- 1.0.0
-
toJson
Description copied from interface:JsonValueSerializes this value as compact JSON text: no insignificant whitespace, members in insertion order, and numbers in the canonical form ofBigDecimal.toString()(1e2becomes1E+2).Strings escape only what JSON requires: the quotation mark, the reverse solidus and the control characters U+0000 to U+001F, using the two-character escapes where they exist. Every other character, U+2028 and U+2029 included, is written as itself.
Unlike
toString(), the result contains every string and number this value holds. It is not the text a value was parsed from, so never verify a signature over it. -
equals
-
hashCode
-
toString
-