Kotlhttps://grokonez.com/kotlin/kotlin-convert-object-tofrom-json-jackson-2-x
Kotlin – Convert Object to/from JSON with Jackson 2.x
This tutorial shows you how to use Jackson 2.x to convert Kotlin object to/from JSON.
I. Technology
- Java 1.8
- Kotlin 1.1.2
- Maven 3.5.1
II. Overview
1. Goal
Convert JSON string/JSON file/JSON url toPerson(name:String,age:Int,messages:List)
Kotlin Object, then convertPerson
object to JSON string/JSON file.2. Steps to do
- add Dependency:
<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.1.2</version> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.8.8</version>
</dependency>
- import
com.fasterxml.jackson.module.kotlin.*
- use ObjectMapper instance:
More at:
https://grokonez.com/kotlin/kotlin-convert-object-tofrom-json-jackson-2-xin – Convert Object to/from JSON with Jackson 2.x
Top comments (0)