# Ktor - How to enable kotlinx.serialization DSL?

**URL:** https://discuss.kotlinlang.org/t/ktor-how-to-enable-kotlinx-serialization-dsl/24121
**Category:** Libraries
**Created:** [February 5, 2022, 1:50pm UTC](https://discuss.kotlinlang.org/t/ktor-how-to-enable-kotlinx-serialization-dsl/24121 "2022-02-05T13:50:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![johnnybaloney](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/johnnybaloney/32/9147_2.png) [@johnnybaloney](https://discuss.kotlinlang.org/u/johnnybaloney)
#### Post date: [February 5, 2022, 1:50pm UTC](https://discuss.kotlinlang.org/t/ktor-how-to-enable-kotlinx-serialization-dsl/24121/1 "2022-02-05T13:50:19Z")

</div>

Hi,

I’m browsing Ktor related resources and came across [Ktor 1.3 release notes](https://blog.jetbrains.com/kotlin/2020/01/ktor-1-3-release/). There I found this:

> Ktor now supports a way to construct a JSON body using the `kotlinx.serialization` DSL:

```auto
client.post("http://localhost:9090") {
contentType(ContentType.Application.Json)
body = json {
"key1" to 123
"map" to json {
"key2" to "abc"
}
}
}

```

> To use it on a client, install JsonFeature and add the ktor-client-serialization dependency.

When I paste this into the editor `json` function is not recognised. How do I enable the kotlinx.serialization DSL? Also the `post` function complains about missing the type parameter.

If I stick `Unit` as a type parameter and use a `JsonObject` as `body` instead everything works fine. But I would like to use the DSL if possible.
