optCountryCode

@Size(value = 2)
fun optCountryCode(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, along with any value that isn't a two-character string.

Return

a two-letter country code if one is found, or null

Parameters

jsonObject

the object from which to retrieve the country code

fieldName

the name of the field in which the country code is stored