Skip to content

Commit

Permalink
remove JsonArrayBuilder addAll varargs JsonElement util
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy committed May 6, 2023
1 parent ec87d84 commit dc46b70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,8 @@ class JsonBuildersTest {
)

assertEquals(
"""[1,"a",false,null,2,"b",true,null]""",
"""[2,"b",true,null]""",
buildJsonArray {
assertTrue {
addAll(
JsonPrimitive(1),
JsonPrimitive("a"),
JsonPrimitive(false),
JsonNull,
)
}
assertTrue {
addAll(
listOf(
Expand All @@ -92,16 +84,8 @@ class JsonBuildersTest {
)

assertEquals(
"""[{},{},{},null,{},{},{},null]""",
"""[{},{},{},null]""",
buildJsonArray {
assertTrue {
addAll(
JsonObject(emptyMap()),
JsonObject(emptyMap()),
JsonObject(emptyMap()),
JsonNull,
)
}
assertTrue {
addAll(
listOf(
Expand All @@ -116,16 +100,8 @@ class JsonBuildersTest {
)

assertEquals(
"""[[],[],[],null,[],[],[],null]""",
"""[[],[],[],null]""",
buildJsonArray {
assertTrue {
addAll(
JsonArray(emptyList()),
JsonArray(emptyList()),
JsonArray(emptyList()),
JsonNull,
)
}
assertTrue {
addAll(
listOf(
Expand All @@ -140,11 +116,8 @@ class JsonBuildersTest {
)

assertEquals(
"""[null,null,null,null]""",
"""[null,null]""",
buildJsonArray {
assertTrue {
addAll(JsonNull, JsonNull)
}
assertTrue {
addAll(listOf(JsonNull, JsonNull))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,6 @@ public fun JsonArrayBuilder.addJsonObject(builderAction: JsonObjectBuilder.() ->
public fun JsonArrayBuilder.addJsonArray(builderAction: JsonArrayBuilder.() -> Unit): Boolean =
add(buildJsonArray(builderAction))

/**
* Adds the given JSON [elements] to a resulting JSON array.
*
* @return `true` if the list was changed as the result of the operation.
*/
@ExperimentalSerializationApi
public fun JsonArrayBuilder.addAll(vararg elements: JsonElement): Boolean {
return addAll(elements.toList())
}

/** Adds the given string [values] to a resulting JSON array. */
@JvmName("addAllStrings")
@ExperimentalSerializationApi
Expand Down

0 comments on commit dc46b70

Please sign in to comment.