usingExtractedPairs
open fun <E> usingExtractedPairs(elements: BiConsumer<T, Consumer<E>>, extractor: JsonWriter.PairExtractor<E>): JsonWriter.Member<T>
Add JSON name/value pairs by extracting values from a series of elements. Typically used with a forEach call, for example:
members.add(Event::getTags).usingExtractedPairs(Iterable::forEach, pairExtractor);
Content copied to clipboard
When used with a named member, the pairs will be added as a new JSON value object:
{
"name": {
"p1": 1,
"p2": 2
}
}
Content copied to clipboard
{
"p1": 1,
"p2": 2
}
Content copied to clipboard
Return
a Member which may be configured further
Parameters
<E>
the element type
elements
callback used to provide the elements
extractor
a PairExtractor used to extract the name/value pair
See also
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. Typically used with a forEach call, for example:
members.add(Event::getTags).usingExtractedPairs(Iterable::forEach, Tag::getName, Tag::getValue);
Content copied to clipboard
When used with a named member, the pairs will be added as a new JSON value object:
{
"name": {
"p1": 1,
"p2": 2
}
}
Content copied to clipboard
{
"p1": 1,
"p2": 2
}
Content copied to clipboard
Return
a Member which may be configured further
Parameters
<E>
the element type
<N>
the name type
<V>
the value type
elements
callback used to provide the elements
nameExtractor
Function used to extract the name
valueExtractor
Function used to extract the value