1 package net.pterodactylus.sone.utils
3 import com.fasterxml.jackson.databind.JsonNode
4 import com.fasterxml.jackson.databind.node.ArrayNode
5 import com.fasterxml.jackson.databind.node.JsonNodeFactory.instance
6 import com.fasterxml.jackson.databind.node.ObjectNode
8 fun jsonObject(block: ObjectNode.() -> Unit): ObjectNode = ObjectNode(instance).apply(block)
9 fun jsonArray(vararg objects: String?): ArrayNode = objects.fold(ArrayNode(instance), ArrayNode::add)
10 fun jsonArray(vararg objects: JsonNode?): ArrayNode = objects.fold(ArrayNode(instance), ArrayNode::add)
12 fun Iterable<ObjectNode>.toArray(): ArrayNode = fold(ArrayNode(instance), ArrayNode::add)