Skip to content

Commit 75adf68

Browse files
committed
Add support for primitive arrays
1 parent fa31c41 commit 75adf68

File tree

2 files changed

+14
-0
lines changed
  • json-schema-validator-objects/src
    • commonMain/kotlin/io/github/optimumcode/json/schema/wrappers/objects
    • commonTest/kotlin/io/github/optimumcode/json/schema/wrappers/objects

2 files changed

+14
-0
lines changed

json-schema-validator-objects/src/commonMain/kotlin/io/github/optimumcode/json/schema/wrappers/objects/Wrappers.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ public fun wrapAsElement(
7777
obj is Map<*, *> -> checkKeysAndWrap(obj, configuration)
7878
obj is List<*> -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
7979
obj is Array<*> -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
80+
obj is LongArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
81+
obj is IntArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
82+
obj is ShortArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
83+
obj is DoubleArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
84+
obj is FloatArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
85+
obj is CharArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
86+
obj is ByteArray -> ListWrapper(obj.map { wrapAsElement(it, configuration) })
8087
obj is Set<*> && configuration.allowSets ->
8188
ListWrapper(obj.map { wrapAsElement(it, configuration) })
8289

json-schema-validator-objects/src/commonTest/kotlin/io/github/optimumcode/json/schema/wrappers/objects/WrappersTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ class WrappersTest : FunSpec() {
3535
emptyMap<String, Any>() to ObjectElement::class,
3636
listOf<Any>() to ArrayElement::class,
3737
emptyArray<Any>() to ArrayElement::class,
38+
byteArrayOf() to ArrayElement::class,
39+
shortArrayOf() to ArrayElement::class,
40+
intArrayOf() to ArrayElement::class,
41+
longArrayOf() to ArrayElement::class,
42+
floatArrayOf() to ArrayElement::class,
43+
doubleArrayOf() to ArrayElement::class,
44+
charArrayOf() to ArrayElement::class,
3845
"test" to PrimitiveElement::class,
3946
't' to PrimitiveElement::class,
4047
42 to PrimitiveElement::class,

0 commit comments

Comments
 (0)