|
6 | 6 | package kotlinx.serialization.json
|
7 | 7 |
|
8 | 8 | import kotlinx.serialization.ExperimentalSerializationApi
|
9 |
| -import kotlin.contracts.* |
| 9 | +import kotlin.contracts.ExperimentalContracts |
| 10 | +import kotlin.contracts.InvocationKind |
| 11 | +import kotlin.contracts.contract |
10 | 12 | import kotlin.jvm.JvmName
|
11 | 13 |
|
12 | 14 | /**
|
@@ -142,6 +144,7 @@ public class JsonArrayBuilder @PublishedApi internal constructor() {
|
142 | 144 | *
|
143 | 145 | * @return `true` if the list was changed as the result of the operation.
|
144 | 146 | */
|
| 147 | + @ExperimentalSerializationApi |
145 | 148 | public fun addAll(elements: Collection<JsonElement>): Boolean =
|
146 | 149 | content.addAll(elements)
|
147 | 150 |
|
@@ -196,38 +199,45 @@ public fun JsonArrayBuilder.addJsonArray(builderAction: JsonArrayBuilder.() -> U
|
196 | 199 | add(buildJsonArray(builderAction))
|
197 | 200 |
|
198 | 201 | /**
|
199 |
| - * Adds the given JSON [element] and [elements] to a resulting JSON array. |
| 202 | + * Adds the given JSON [elements] to a resulting JSON array. |
200 | 203 | *
|
201 | 204 | * @return `true` if the list was changed as the result of the operation.
|
202 | 205 | */
|
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()) |
205 | 209 | }
|
206 | 210 |
|
207 | 211 | /** Adds the given string [values] to a resulting JSON array. */
|
208 | 212 | @JvmName("addAllStrings")
|
| 213 | +@ExperimentalSerializationApi |
209 | 214 | public fun JsonArrayBuilder.addAll(values: Collection<String?>): Boolean =
|
210 | 215 | addAll(values.map(::JsonPrimitive))
|
211 | 216 |
|
212 | 217 | /** Adds the given boolean [values] to a resulting JSON array. */
|
213 | 218 | @JvmName("addAllBooleans")
|
| 219 | +@ExperimentalSerializationApi |
214 | 220 | public fun JsonArrayBuilder.addAll(values: Collection<Boolean?>): Boolean =
|
215 | 221 | addAll(values.map(::JsonPrimitive))
|
216 | 222 |
|
217 | 223 | /** Adds the given numeric [values] to a resulting JSON array. */
|
218 | 224 | @JvmName("addAllNumbers")
|
| 225 | +@ExperimentalSerializationApi |
219 | 226 | public fun JsonArrayBuilder.addAll(values: Collection<Number?>): Boolean =
|
220 | 227 | addAll(values.map(::JsonPrimitive))
|
221 | 228 |
|
222 | 229 | /** Adds the given string [values] to a resulting JSON array. */
|
| 230 | +@ExperimentalSerializationApi |
223 | 231 | public fun JsonArrayBuilder.addAll(vararg values: String?): Boolean =
|
224 | 232 | addAll(values.toList())
|
225 | 233 |
|
226 | 234 | /** Adds the given boolean [values] to a resulting JSON array. */
|
| 235 | +@ExperimentalSerializationApi |
227 | 236 | public fun JsonArrayBuilder.addAll(vararg values: Boolean?): Boolean =
|
228 | 237 | addAll(values.toList())
|
229 | 238 |
|
230 | 239 | /** Adds the given numeric [values] to a resulting JSON array. */
|
| 240 | +@ExperimentalSerializationApi |
231 | 241 | public fun JsonArrayBuilder.addAll(vararg values: Number?): Boolean =
|
232 | 242 | addAll(values.toList())
|
233 | 243 |
|
|
0 commit comments