Question: I'm trying to create an autocomplete which allows the user to enter in multiple values. The options are too many so I need to do the filtering on the backend. So for every new value the user types, new options come from the backend.

Getting this warning: "Material-UI: The value provided to Autocomplete is invalid. None of the options match with...You can use the `getOptionSelected` prop to customize the equality test."

```
 <Autocomplete
   onChange={(_event, newVal) => setValue(newVal)}
   multiple={multiple}
   loading={loading}
   loadingText="Searching..."
   defaultValue={defaultValue}
   options={options}
   filterOptions={(options, _state) => options}
   getOptionLabel={(option) => option.label}
   getOptionSelected={(option, value) => _.isEqual(option, value)}
   renderInput={(params) => (
     <TextField
     {...params}
     {...textFieldProps}
      onChange={queryChanged}
      inputlabelprops={{ shrink: true }}
      />
    )}
 />

```

I understand why the warning is coming, the older values aren't present in the options for the new query. But is there any way to get rid of this warning? Or Am I approaching this incorrectly? Thanks

Answer: 
Default values [are not encoded](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#defaults-are-not-encoded) by default in `kotlinx-serialization`:

[This place in the docs](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#encoding-defaults) describes how you can customize this behaviour:

```kotlin
val format = Json { encodeDefaults = true }

```

In the specific case of using this in Ktor, you can customize it this way:

```kotlin
install(JsonFeature) {
    serializer = KotlinxSerializer(kotlinx.serialization.json.Json {
        encodeDefaults = true
    })
}

```

If both sides of the communication use the same data model, you shouldn't need this though. They will both use the default value properly and simply save bandwidth by not writing it explicitly.

---

EDIT: here is how you would configure this same thing in Ktor 2.0:

```kotlin
install(ContentNegotiation) {
    json(Json {
        encodeDefaults = true
    })
}

```

See <https://ktor.io/docs/serialization-client.html#register_json>
You need `encodeDefaults = true`
See [this issue](https://github.com/Kotlin/kotlinx.serialization/issues/1154) for more information