Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/JSON/Kotlin/json.kotlin
Normal file
15
Task/JSON/Kotlin/json.kotlin
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// version 1.2.21
|
||||
|
||||
data class JsonObject(val foo: Int, val bar: Array<String>)
|
||||
|
||||
data class JsonObject2(val ocean: String, val blue: Array<Int>)
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
// JSON to object
|
||||
val data: JsonObject = JSON.parse("""{ "foo": 1, "bar": ["10", "apples"] }""")
|
||||
println(JSON.stringify(data))
|
||||
|
||||
// object to JSON
|
||||
val data2 = JsonObject2("water", arrayOf(1, 2))
|
||||
println(JSON.stringify(data2))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue