Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace jackson and js native with kotlinx-serialization json parsing (…
…#2006) * pushing initial work for WIP review * fix pretty printing of raw json * fix a bunch of json formatting issues * kotlinx-serialization parses ints to ints not longs * fix json int comparison * add long test * get EqualTest jvm tests passing * move JsonMatchers into common * collapse some of the MPP json code * fix long/int issue in js tests * cleanup and bump plugin version * use kotlin version from Libs * make compare functions internal and add a couple tests
- Loading branch information
1 parent
e0445fd
commit 2fb3188
Showing
13 changed files
with
406 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...rtions/kotest-assertions-json/src/commonMain/kotlin/io/kotest/assertions/json/wrappers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.kotest.assertions.json | ||
|
||
import kotlinx.serialization.json.JsonArray | ||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.JsonNull | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.JsonPrimitive | ||
import kotlinx.serialization.json.booleanOrNull | ||
import kotlinx.serialization.json.contentOrNull | ||
import kotlinx.serialization.json.doubleOrNull | ||
import kotlinx.serialization.json.floatOrNull | ||
import kotlinx.serialization.json.intOrNull | ||
import kotlinx.serialization.json.longOrNull | ||
|
||
fun JsonElement.toJsonNode(): JsonNode = when (this) { | ||
JsonNull -> JsonNode.NullNode | ||
is JsonObject -> JsonNode.ObjectNode(entries.map { it.key to it.value.toJsonNode() }.toMap()) | ||
is JsonArray -> JsonNode.ArrayNode(map { it.toJsonNode() }) | ||
is JsonPrimitive -> when { | ||
intOrNull != null -> JsonNode.IntNode(intOrNull!!) | ||
longOrNull != null -> JsonNode.LongNode(longOrNull!!) | ||
doubleOrNull != null -> JsonNode.DoubleNode(doubleOrNull!!) | ||
floatOrNull != null -> JsonNode.FloatNode(floatOrNull!!) | ||
booleanOrNull != null -> JsonNode.BooleanNode(booleanOrNull!!) | ||
contentOrNull != null -> JsonNode.StringNode(contentOrNull!!) | ||
else -> error("Unsupported kotlinx-serialization type $this") | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
...sertions/kotest-assertions-json/src/jsMain/kotlin/io.kotest.assertions.json/jsmatchers.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...assertions/kotest-assertions-json/src/jsMain/kotlin/io.kotest.assertions.json/wrappers.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.