Replace get notifications ajax page with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / utils / Json.kt
index 2ee54ee..71c8e81 100644 (file)
@@ -6,8 +6,19 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory.instance
 import com.fasterxml.jackson.databind.node.ObjectNode
 
 fun jsonObject(block: ObjectNode.() -> Unit): ObjectNode = ObjectNode(instance).apply(block)
-fun jsonObject(vararg properties: Pair<String, String>) = jsonObject {
-       properties.forEach { put(it.first, it.second) }
+
+fun jsonObject(vararg properties: Pair<String, Any>) = jsonObject {
+       properties.forEach {
+               it.second.let { value ->
+                       when (value) {
+                               is String -> put(it.first, value)
+                               is Int -> put(it.first, value)
+                               is Long -> put(it.first, value)
+                               is Boolean -> put(it.first, value)
+                               else -> Unit
+                       }
+               }
+       }
 }
 
 fun jsonArray(vararg objects: String?): ArrayNode = objects.fold(ArrayNode(instance), ArrayNode::add)