toJsonRepresentation

inline fun <T> T.toJsonRepresentation(omitNulls: Boolean = true): Json

Maps value of subtype of T to Json.

T can be one of the following:

  • String

  • Number and its subclasses

  • Boolean

  • Enum

  • Any

  • T?

  • Json and its subclasses

  • class with custom JsonMapper

  • List, Sequence, Iterable, Collection, Map

  • class with properties of type T1, T2, ... Tn

Parameters

omitNulls

enables omitting of null properties during mapping.

Throws

if provided type cannot be mapped to Json.