Skip to content

Commit 8b73cfc

Browse files
committed
add @ExperimentalSerializationApi to new funcions, tidy addAll(vararg elements: JsonElement)
1 parent 8354df5 commit 8b73cfc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
package kotlinx.serialization.json
77

88
import kotlinx.serialization.ExperimentalSerializationApi
9-
import kotlin.contracts.*
9+
import kotlin.contracts.ExperimentalContracts
10+
import kotlin.contracts.InvocationKind
11+
import kotlin.contracts.contract
1012
import kotlin.jvm.JvmName
1113

1214
/**
@@ -142,6 +144,7 @@ public class JsonArrayBuilder @PublishedApi internal constructor() {
142144
*
143145
* @return `true` if the list was changed as the result of the operation.
144146
*/
147+
@ExperimentalSerializationApi
145148
public fun addAll(elements: Collection<JsonElement>): Boolean =
146149
content.addAll(elements)
147150

@@ -196,38 +199,45 @@ public fun JsonArrayBuilder.addJsonArray(builderAction: JsonArrayBuilder.() -> U
196199
add(buildJsonArray(builderAction))
197200

198201
/**
199-
* Adds the given JSON [element] and [elements] to a resulting JSON array.
202+
* Adds the given JSON [elements] to a resulting JSON array.
200203
*
201204
* @return `true` if the list was changed as the result of the operation.
202205
*/
203-
public fun JsonArrayBuilder.addAll(element: JsonElement, vararg elements: JsonElement): Boolean {
204-
return addAll(listOf(element) + elements)
206+
@ExperimentalSerializationApi
207+
public fun JsonArrayBuilder.addAll(vararg elements: JsonElement): Boolean {
208+
return addAll(elements.toList())
205209
}
206210

207211
/** Adds the given string [values] to a resulting JSON array. */
208212
@JvmName("addAllStrings")
213+
@ExperimentalSerializationApi
209214
public fun JsonArrayBuilder.addAll(values: Collection<String?>): Boolean =
210215
addAll(values.map(::JsonPrimitive))
211216

212217
/** Adds the given boolean [values] to a resulting JSON array. */
213218
@JvmName("addAllBooleans")
219+
@ExperimentalSerializationApi
214220
public fun JsonArrayBuilder.addAll(values: Collection<Boolean?>): Boolean =
215221
addAll(values.map(::JsonPrimitive))
216222

217223
/** Adds the given numeric [values] to a resulting JSON array. */
218224
@JvmName("addAllNumbers")
225+
@ExperimentalSerializationApi
219226
public fun JsonArrayBuilder.addAll(values: Collection<Number?>): Boolean =
220227
addAll(values.map(::JsonPrimitive))
221228

222229
/** Adds the given string [values] to a resulting JSON array. */
230+
@ExperimentalSerializationApi
223231
public fun JsonArrayBuilder.addAll(vararg values: String?): Boolean =
224232
addAll(values.toList())
225233

226234
/** Adds the given boolean [values] to a resulting JSON array. */
235+
@ExperimentalSerializationApi
227236
public fun JsonArrayBuilder.addAll(vararg values: Boolean?): Boolean =
228237
addAll(values.toList())
229238

230239
/** Adds the given numeric [values] to a resulting JSON array. */
240+
@ExperimentalSerializationApi
231241
public fun JsonArrayBuilder.addAll(vararg values: Number?): Boolean =
232242
addAll(values.toList())
233243

0 commit comments

Comments
 (0)