Member

class Member<T>

A member that contributes JSON. Typically, a member will contribute a single name/value pair based on an extracted value. They may also contribute more complex JSON structures when configured with one of the using(...) methods.

The when(...) methods may be used to filter a member (omit it entirely from the JSON). The as method can be used to adapt to a different type.

Parameters

<T>

the member type

Functions

Link copied to clipboard
open fun <R> as(adapter: (T) -> R): JsonWriter.Member<R>
Adapt the value by applying the given Function.
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun <E, N, V> usingExtractedPairs(elements: BiConsumer<T, Consumer<E>>, nameExtractor: (E) -> N, valueExtractor: (E) -> V): JsonWriter.Member<T>
Add JSON name/value pairs by extracting values from a series of elements.
Link copied to clipboard
Add JSON based on further Members configuration.
Link copied to clipboard
Add JSON name/value pairs.
Link copied to clipboard
open fun when(predicate: Predicate<T>): JsonWriter.Member<T>
Only include this member when the given predicate matches.
Link copied to clipboard
Only include this member when it is not null and has a toString() that is not zero length.
Link copied to clipboard
open fun whenNot(predicate: Predicate<T>): JsonWriter.Member<T>
Only include this member when the given predicate does not match.
Link copied to clipboard
Only include this member when it is not empty (See isEmpty for details).
Link copied to clipboard
Only include this member when its value is not null.
open fun whenNotNull(extractor: (T) -> out Any): JsonWriter.Member<T>
Only include this member when an extracted value is not null.