Skip to content

Commit 19afcda

Browse files
committed
Stabilize JsonElement DSL functions with Nothing? overload
They help avoiding writing `JsonPrimitive(null as String?)`
1 parent d17db9f commit 19afcda

File tree

2 files changed

+0
-3
lines changed

2 files changed

+0
-3
lines changed

formats/json/commonMain/src/kotlinx/serialization/json/JsonElement.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public fun JsonPrimitive(value: String?): JsonPrimitive {
101101
}
102102

103103
/** Creates [JsonNull]. */
104-
@ExperimentalSerializationApi
105104
@Suppress("FunctionName", "UNUSED_PARAMETER") // allows to call `JsonPrimitive(null)`
106105
public fun JsonPrimitive(value: Nothing?): JsonNull = JsonNull
107106

formats/json/commonMain/src/kotlinx/serialization/json/JsonElementBuilders.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public fun JsonObjectBuilder.put(key: String, value: String?): JsonElement? = pu
122122
* Returns the previous value associated with [key], or `null` if the key was not present.
123123
*/
124124
@IgnorableReturnValue
125-
@ExperimentalSerializationApi
126125
@Suppress("UNUSED_PARAMETER") // allows to call `put("key", null)`
127126
public fun JsonObjectBuilder.put(key: String, value: Nothing?): JsonElement? = put(key, JsonNull)
128127

@@ -189,7 +188,6 @@ public fun JsonArrayBuilder.add(value: String?): Boolean = add(JsonPrimitive(val
189188
* Always returns `true` similarly to [ArrayList] specification.
190189
*/
191190
@IgnorableReturnValue
192-
@ExperimentalSerializationApi
193191
@Suppress("UNUSED_PARAMETER") // allows to call `add(null)`
194192
public fun JsonArrayBuilder.add(value: Nothing?): Boolean = add(JsonNull)
195193

0 commit comments

Comments
 (0)