https://kotlinlang.org logo
#ktor
Title
# ktor
r

Rahul Rawat

01/08/2022, 3:35 PM
Been trying to make a ktor server but unable to understand why the response is escaping string values like the following
Copy code
{
  "address": {
    "id": 1,
    "firstname": "\"Rahul\"",
    "lastname": "\"Rawat\"",
    "address1": "\"Address1\"",
    "address2": "\"Address2\"",
    "city": "\"City\"",
    "zipCode": "\"ZipCode\"",
    "phone": "\"80808080\"",
    "state_name": "\"State\"",
    "alternative_phone": "\"Alternative\"",
    "company": "\"Company\"",
    "state_id": 1,
    "country_id": 2
  }
}
My server looks like the following
Copy code
install(ContentNegotiation) {
            json(Json {
                prettyPrint = true
                isLenient = true
            })
        }
Please someone help.
d

Dominaezzz

01/08/2022, 3:50 PM
What does the response type look like?
r

Rahul Rawat

01/08/2022, 4:12 PM
Json as you can see in the following
d

Dominaezzz

01/08/2022, 4:13 PM
Are you sure you haven't put the
"
in the properties by accident before responding?
☝️ 1
r

Rahul Rawat

01/08/2022, 4:14 PM
Now I feel stupid 😅
d

Dominaezzz

01/08/2022, 4:15 PM
😄
r

Rahul Rawat

01/08/2022, 4:15 PM
Thanks @Dominaezzz
d

Dominaezzz

01/08/2022, 4:15 PM
np 👍🏼
4 Views