Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gk0Wk committed Aug 7, 2023
1 parent ac8abf9 commit 369f408
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .idea/dictionaries/Sttot.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/test/kotlin/1.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory

data class MyClass(
val name: String,
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
val values: IntArray
)

fun main() {
val objectMapper = ObjectMapper(YAMLFactory())

// 序列化对象
val obj = MyClass("example", intArrayOf(1, 2, 3))
val yaml = objectMapper.writeValueAsString(obj)
println(yaml)
}

0 comments on commit 369f408

Please sign in to comment.