Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 1.47 KB

readme.adoc

File metadata and controls

52 lines (42 loc) · 1.47 KB

Jackson Singleton Access

lib jackson singleton Version Required JVM Version API Docs

Provides a singleton over a universally configured FasterXML Jackson JSON ObjectMapper instance API.

This is intended to unify the access of Jackson object mappers to avoid multiple separately configured instances floating about in a single project.

Additionally, provides a set of helper/utility methods for working with Jackson APIs in Kotlin.

Usage

build.gradle.kts
dependencies {
  implementation("org.veupathdb.lib:jackson-singleton:3.2.0")
}

Examples

import org.veupathdb.lib.jackson.Json

// Creates a new ObjectNode representing the JSON:
// {
//   "key": "value"
// }
fun createObject(): ObjectNode = Json.new {
  put("key", "value")
}

// Parses a `Person` instance.
//
// This method uses the return type Person to shortcut
// to Mapper.readValue(inputStream, Person::class.java)
fun parseJson(): Person =
  Json.parse(File("foo.json").inputStream())