Hello everyone I’m sending an object in ktor one ...
# ktor
r
Hello everyone I’m sending an object in ktor one of the objects variables is an empty array, when I make the request this empty array isn’t found in the request I think ktor ignores it, any one knows why this is happening and how it could be fixed
c
Can you specify what you expect? Query parameters? Json Body? XML Body?
r
The error isn’t in the response, it’s in the request I need to send this as request body
Copy code
{
  "businessHours": [
    {
      "day_name": "tuesday",
      "end_time": 1735102800000,
      "isWorking": true,
      "slots": [],
      "start_time": 1735099200000
    }
  ],
  "store_id": "5c56f50266ea4b17449c506f"
}
but ktor removes the "slots": [] ans send that
Copy code
{
  "businessHours": [
    {
      "day_name": "tuesday",
      "end_time": 1735102800000,
      "isWorking": true,
      "start_time": 1735099200000
    }
  ],
  "store_id": "5c56f50266ea4b17449c506f"
}
c
What are you using for content negotiation?
r
this
Copy code
install(ContentNegotiation) {
    json(Json {
        ignoreUnknownKeys = true
        explicitNulls = false
    })
}
c
is it a
default
parameter for
emptyList
?
then you need
Copy code
Json {
    encodeDefaults = true,
}
r
it worked thank you very much @Chrimaeon
👍🏼 1