All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.at.asitplus.jsonpath.JsonPath.kt Maven / Gradle / Ivy

Go to download

Kotlin Multiplatform library for using Json Paths as specified in [RFC9535](https://datatracker.ietf.org/doc/rfc9535/)

The newest version!
package at.asitplus.jsonpath

import at.asitplus.jsonpath.core.JsonPathCompiler
import at.asitplus.jsonpath.core.JsonPathFunctionExtension
import at.asitplus.jsonpath.core.NodeList
import kotlinx.serialization.json.JsonElement

class JsonPath(
    jsonPathExpression: String,
    compiler: JsonPathCompiler = JsonPathDependencyManager.compiler,
    functionExtensionRetriever: (String) -> JsonPathFunctionExtension<*>? = JsonPathDependencyManager.functionExtensionRepository::getExtension
) {
    private val query = compiler.compile(
        jsonPath = jsonPathExpression,
        functionExtensionRetriever = functionExtensionRetriever,
    )

    fun query(jsonElement: JsonElement): NodeList {
        return query.invoke(jsonElement)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy