Class JsonList
- All Implemented Interfaces:
JsonBaseNode, JsonListNode, JsonPart, Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess, SequencedCollection<Object>
To parse json array string:
JsonListNode jsonList = JsonList.parse("[1, 4, 0, 1]");
//To get the value from an index
int intValueAt1 = jsonList.getValueAsInteger(1);
System.out.println("intValueAt1 = " + intValueAt1); // intValueAt1 = 4
//Prints the json string
System.out.println("toJsonString = " + jsonList.toJsonString()); // toJsonString = [1,4,0,1]
- Since:
- 12.0.4
- See Also:
-
Field Summary
Fields inherited from class AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class AbstractCollection
containsAllMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface JsonBaseNode
toOutputStreamModifier and TypeMethodDescriptiondefault voidtoOutputStream(OutputStream outputStream, Charset charset) Methods inherited from interface JsonListNode
addEnum, convertTo, getValueAsBigDecimal, getValueAsBigInteger, getValueAsBoolean, getValueAsDouble, getValueAsEnum, getValueAsInteger, getValueAsJsonBaseNode, getValueAsJsonListNode, getValueAsJsonMapNode, getValueAsJsonValue, getValueAsLong, getValueAsShort, getValueAsString, getValueAsString, sizeAwareConvertTo, toBigJsonString, toJsonString, toOutputStream, toWffBMArray, toWffBMArrayModifier and TypeMethodDescriptiondefault <E extends Enum<E>>
booleanaddEnum(E value) default <T,U> U convertTo(Supplier<T> jsonObjectSupplier, TriConsumer<T, String, Object> putOperation, Supplier<U> jsonArraySupplier, BiConsumer<U, Object> addOperation, boolean parseJsonValue) class CustomJsonMap extends JsonMap { } class CustomList extends JsonList { } JsonMap jsonMap = new JsonMap(); jsonMap.put("number", new JsonValue("14", JsonValueType.NUMBER)); jsonMap.put("string", "string value"); jsonMap.put("bool", true); jsonMap.put("fornull1", JsonValue.NULL); jsonMap.put("fornull2", null); JsonList jsonList = new JsonList(); jsonList.add(jsonMap); CustomList convertedObject = jsonList.convertTo( CustomJsonMap::new, CustomJsonMap::put, CustomList::new, CustomList::add, true);default BigDecimalgetValueAsBigDecimal(int index) default BigIntegergetValueAsBigInteger(int index) default BooleangetValueAsBoolean(int index) default DoublegetValueAsDouble(int index) default <E extends Enum<E>>
EgetValueAsEnum(Class<E> enumClass, int index) default IntegergetValueAsInteger(int index) default JsonBaseNodegetValueAsJsonBaseNode(int index) default JsonListNodegetValueAsJsonListNode(int index) default JsonMapNodegetValueAsJsonMapNode(int index) default JsonValuegetValueAsJsonValue(int index) default LonggetValueAsLong(int index) default ShortgetValueAsShort(int index) default StringgetValueAsString(int index) default StringgetValueAsString(int index, boolean decodeUnicodeCharsSequence) default <T,U> U sizeAwareConvertTo(Function<Integer, T> jsonObjectSupplier, TriConsumer<T, String, Object> putOperation, Function<Integer, U> jsonArraySupplier, BiConsumer<U, Object> addOperation, boolean parseJsonValue) class CustomJsonMap extends JsonMap { public CustomJsonMap(final int initialCapacity) { super(initialCapacity); } } class CustomList extends JsonList { public CustomList(final int initialCapacity) { super(initialCapacity); } } JsonMap jsonMap = new JsonMap(); jsonMap.put("number", new JsonValue("14", JsonValueType.NUMBER)); jsonMap.put("string", "string value"); jsonMap.put("bool", true); jsonMap.put("fornull1", JsonValue.NULL); jsonMap.put("fornull2", null); JsonList jsonList = new JsonList(); jsonList.add(jsonMap); CustomList convertedObject = jsonList.sizeAwareConvertTo( CustomJsonMap::new, CustomJsonMap::put, CustomList::new, CustomList::add, true);default Stringdefault Stringdefault voidtoOutputStream(OutputStream outputStream, Charset charset, boolean flushOnWrite) default WffBMArrayNB: The array should not contain null values.default WffBMArraytoWffBMArray(boolean parseJsonValue) NB: The array should not contain null values.Methods inherited from interface List
containsAll, reversed
-
Constructor Details
-
JsonList
public JsonList(int initialCapacity) -
JsonList
public JsonList() -
JsonList
-
-
Method Details
-
parse
-
toString
- Overrides:
toStringin classAbstractCollection<Object>
-