Skip to content

Varargs signature validation error #48

@alturkovic

Description

@alturkovic

Hi!

I am trying to implement an adapter to use with jsonata for the following interface:

interface JsonExtension {
    fun call(node: JsonNode, arguments: List<JsonNode>): JsonNode
}

I implemented the following class to bridge the gap between the two interfaces:

class ExtensionFunction(
    val extension: JsonExtension
) : Jsonata.JFunctionCallable {
    override fun call(input: Any?, args: MutableList<Any?>?): JsonNode {
        val mapper = jacksonObjectMapper()
        val node: JsonNode = mapper.valueToTree(input)
        val arguments: List<JsonNode> = args?.let { mapper.convertValue(it) } ?: emptyList()
        return extension.call(node, arguments)
    }
}

I am trying to register it with jsonata like this:

val extension = object : JsonExtension {
    override fun call(node: JsonNode, arguments: List<JsonNode>): JsonNode {
        println("Input: '$node' and args: $arguments")
        return node
    }
}

registerFunction("myExtension", Jsonata.JFunction(ExtensionFunction(extension), "???"))

But I cannot figure out how to write a varargs signature. I want this function to accept any number of any type of json arguments and return any type of result, something like the following in Java:

Object call(Object... args);

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions