castToJson

@JvmName(name = "castToJsonReceiverType")
inline fun <T : Any, E : T?> ExpressionWithColumnType<E>.castToJson(): CastToJson<E>

Specifies a casting of the calling expression's data type to the JSON data type. This is useful when it may be necessary to cast a JSONB column or expression to JSON, but some dialects also support casting text types as well.

Note: Dialects that do not support a JSON-specific constructor will generate a CAST .. AS json_type clause. Some dialects, like MariaDB, do not support casting to JSON. Please check the documentation or consider using castTo() directly.

Return

An expression with a JsonColumnType that can handle the same data as the calling expression, but in JSON format.

See also


Specifies a casting of the calling expression's data type to the JSON data type. This is useful when it may be necessary to cast a type such as text to a JSON type that can be handled by a serializable class on the client-side.

Note: Dialects that do not support a JSON-specific constructor will generate a CAST .. AS json_type clause. Some dialects, like MariaDB, do not support casting to JSON. Please check the documentation or consider using castTo() directly.

Return

An expression with a JsonColumnType that can handle the type specified by parameter T in JSON format.

See also