https://kotlinlang.org logo
#http4k
Title
# http4k
e

Emile Achadde

03/19/2020, 3:51 PM
@s4nchez I looked at the documents you provided and got lost ... I have to parse a string in json format like this one '{"name" : "some-name", "age": 30}" what is the simplest way to get "some-name" and 30 ?
d

dave

03/19/2020, 8:28 PM
You have 2 options here -you can create a data class and auto-convert the JSON string to an instance of that class (using the auto-marshalling that @s4nchez posted). -alternatively, you can convert the String to a JSON node and then extract the fields manually. For simplicity I suggest the former.
for both you need to import an JSON module and then either use
Body.auto
or (for instance)
Jackson.parse