feat(android): allow JSObject::getString to return null

This commit is contained in:
Lucas Nogueira 2023-04-29 12:50:04 -03:00
parent 19cd0e4960
commit e68a08da51
No known key found for this signature in database
GPG Key ID: FFEA6C72E73482F1

View File

@ -13,14 +13,13 @@ class JSObject : JSONObject {
constructor(obj: JSONObject, names: Array<String>) : super(obj, names)
override fun getString(key: String): String {
return getString(key, "")
return getString(key, "")!!
}
fun getString(key: String, defaultValue: String): String {
fun getString(key: String, defaultValue: String?): String? {
try {
val value = super.getString(key)
if (!super.isNull(key)) {
return value
return super.getString(key)
}
} catch (_: JSONException) {
}