fromJson

fun <T : Any> fromJson(json: String, clazz: Class<T>): T

Converts a JSON string to an object of the specified class.

Return

An object of the specified class.

Parameters

json

The JSON string to convert.

clazz

The class of the object to create.

Throws

If there is an error processing the JSON string.


fun <T : Any> fromJson(json: String, ref: TypeReference<T>): T

Converts a JSON string to an object of the specified TypeReference.

Return

An object of the specified TypeReference.

Parameters

json

The JSON string to convert.

ref

The TypeReference of the object to create.

Throws

If there is an error processing the JSON string.