toJSONObject

fun String.toJSONObject(): JSONObject

Converts the current string to a JSONObject instance. The string must be a valid JSON; otherwise, an IllegalArgumentException is thrown.

Return

A JSONObject representation of the string.

Throws

If the string is not a valid JSON.