toDataObject

inline fun <T : Any> Map<String, Any?>.toDataObject(): T

Converts a map to a data class instance.

Keys are matched to properties by converting each property name from camelCase to snake_case; PgName overrides that per property. A key the class has no property for is ignored. A key that is absent and one whose value is null are treated differently — see instantiateDataObject.

Return

The instantiated object.

Type Parameters

T

The data class to build.

Throws

if a value does not match its property's type, or a non-nullable property has no value to take. The property name is added to the exception's path.


fun <T : Any> Map<String, Any?>.toDataObject(kClass: KClass<T>): T

Converts a map to a data class instance.

Keys are matched to properties by converting each property name from camelCase to snake_case; PgName overrides that per property. A key the class has no property for is ignored. A key that is absent and one whose value is null are treated differently — see instantiateDataObject.

Return

The instantiated object.

Parameters

kClass

The data class to build.

Throws

if a value does not match its property's type, or a non-nullable property has no value to take. The property name is added to the exception's path.