writeMap

fun <Key> writeMap(map: Map<Key, JSONFriendly>, keyCreator: (Key) -> String)

Write a map keyed by an arbitrary type to JSONFriendly as a JSONObject with the map keys transformed into JSONObject keys using the key creator lambda and the corresponding map values as the JSONObject field values.

Parameters

Key

The type of the Map's key.

map

The Map to serialize into this JSONWriter.

keyCreator

Accepts the map key and answers a String that is used as the JSONObject field key for the associated value.


fun <Key, Value> writeMap(map: Map<Key, Value>, pairCreator: (Key, Value) -> Pair<String, JSONFriendly>)

Write a map keyed by an arbitrary type to another arbitrary type as a JSONObject with the map keys transformed into JSONObject keys using the key creator lambda and the corresponding map values transformed into JSONFriendly using the value creator lambda as the JSONObject field values.

Parameters

Key

The type of the Map's key.

Value

The type of the Map's value.

map

The Map to serialize into this JSONWriter.

pairCreator

Accepts the map key and the associated value and answers a Pair of String to JSONFriendly with the first element of the pair used as the JSONObject field key and the second element of the pair as the associated field value.