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

ristianNHenriksen.KotlinJson.1.0.source-code.JsonParser.kt Maven / Gradle / Ivy

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper

/**
 * Created by Christian on 17/09/2016.
 */

object JsonParser {
    private val mapper = ObjectMapper()

    /**
     * Parse a Json string into a Json object.
     *
     * @param string A valid json string.
     * @return The Json object parsed from the string.
     */
    fun parse(string: String): Json {
        val value: Map = mapper.readValue(string, JsonMapType())
        return Json(value)
    }

    class JsonMapType: TypeReference>() {}

    class JsonArrayType: TypeReference>() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy