add to json model tests
This commit is contained in:
parent
e5710d8a26
commit
a1c02b739d
@ -7,6 +7,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(project(":cubetiq-utils"))
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
|
|
||||||
|
@ -1,11 +1,32 @@
|
|||||||
package com.cubetiqs.modules.example
|
package com.cubetiqs.modules.example
|
||||||
|
|
||||||
|
import com.cubetiqs.enterprise.comutils.json.toJson
|
||||||
|
import com.cubetiqs.enterprise.comutils.json.toModel
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent
|
||||||
import org.springframework.boot.runApplication
|
import org.springframework.boot.runApplication
|
||||||
|
import org.springframework.context.event.EventListener
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
class SampleModuleExampleApplication
|
class SampleModuleExampleApplication {
|
||||||
|
data class Person (
|
||||||
|
val name: String,
|
||||||
|
val age: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
@EventListener(ApplicationReadyEvent::class)
|
||||||
|
fun onApplicationReady() {
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"name": "Sambo",
|
||||||
|
"age": 24
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
val node = json.toModel<Person>()
|
||||||
|
print(node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
runApplication<SampleModuleExampleApplication>(*args)
|
runApplication<SampleModuleExampleApplication>(*args)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user