optString

fun optString(jsonObject: JSONObject?, @Size(min = 1) fieldName: String): String?

Calls through to JSONObject.optString while safely converting the raw string "null" and the empty string to null. Will not throw an exception if the field isn't found.

Return

the value stored in the field, or null if the field isn't present

Parameters

jsonObject

the input object

fieldName

the optional field name