Skip to content

Commit

Permalink
do not allow passing of nullable types into getOrNull() - it already …
Browse files Browse the repository at this point in the history
…returns a nullable type
  • Loading branch information
angryziber committed Feb 19, 2024
1 parent 6d72ed0 commit 49eaaa1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion json/src/JsonNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typealias JsonList = List<JsonNode>

@kotlin.internal.HidesMembers
inline fun <T: Any> JsonNode.get(key: String) = (get(key) ?: throw NullPointerException("$key is absent")) as T
inline fun <T> JsonNode.getOrNull(key: String) = get(key) as T?
inline fun <T: Any> JsonNode.getOrNull(key: String) = get(key) as T?

inline fun JsonNode.getString(key: String) = get<String>(key)
inline fun JsonNode.getInt(key: String) = get<Number>(key).toInt()
Expand Down

0 comments on commit 49eaaa1

Please sign in to comment.