generated from arrow-kt/Arrow-KMP-Template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample-readme-01.kt
38 lines (34 loc) · 932 Bytes
/
example-readme-01.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This file was automatically generated from README.md by Knit tool. Do not edit.
@file:Suppress("InvalidPackageDeclaration")
package com.example.exampleReadme01
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import arrow.optics.*
import io.github.nomisrev.*
import arrow.optics.typeclasses.*
private const val JSON_STRING = """
{
"name": "Arrow",
"address": {
"city": "Functional Town",
"street": {
"number": 1337,
"name": "Functional street"
}
},
"employees": [
{
"name": "John",
"lastName": "doe"
},
{
"name": "Jane",
"lastName": "doe"
}
]
}"""
fun main(): Unit {
val json: JsonElement = Json.decodeFromString(JSON_STRING)
val name: Optional<JsonElement, String> = JsonPath.select("name").string
println(name.modify(json, String::uppercase))
}