Skip to content

Commit f0eda64

Browse files
committed
Added Supression of unchecked casts in JSONArray and JSONObject
1 parent c003aea commit f0eda64

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/main/kotlin/nz/ahw/kompat/jsonlib/JSONArray.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class JSONArray(override val json: SFJSONArray = SFJSONArray()): JSON, Iterable<
6767

6868
val indices: IntRange get() = 0 until size
6969

70+
@Suppress("UNCHECKED_CAST")
7071
override fun iterator(): Iterator<Any> = json.iterator() as Iterator<Any>
7172

7273
operator fun minus(index: Int): JSONArray { remove(index); return this }
@@ -112,7 +113,10 @@ class JSONArray(override val json: SFJSONArray = SFJSONArray()): JSON, Iterable<
112113

113114
val size: Int get() = json.size
114115

116+
@Suppress("UNCHECKED_CAST")
115117
fun toArray(): Array<Any> = SFJSONArray.toArray(json) as Array<Any>
118+
119+
@Suppress("UNCHECKED_CAST")
116120
fun toList(): List<Any> = SFJSONArray.toCollection(json).toList() as List<Any>
117121
override fun toString(): String = json.toString()
118122

src/main/kotlin/nz/ahw/kompat/jsonlib/JSONObject.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class JSONObject(override val json: SFJSONObject = SFJSONObject()): JSON {
6464

6565
override fun hashCode(): Int = json.hashCode()
6666

67+
@Suppress("UNCHECKED_CAST")
6768
val keys: Set<String> get() = json.keys as Set<String>
6869

6970
operator fun minus(key: String): JSONObject { remove(key); return this }
@@ -103,6 +104,7 @@ class JSONObject(override val json: SFJSONObject = SFJSONObject()): JSON {
103104
inline fun <reified T> toBean(): T = SFJSONObject.toBean(json, T::class.java) as T
104105
override fun toString(): String = json.toString()
105106

107+
@Suppress("UNCHECKED_CAST")
106108
val values: Collection<Any> get() = json.values as Collection<Any>
107109

108110
companion object {

0 commit comments

Comments
 (0)