Is it possible to tell a `SerializersModule` to look for an attribute called `name` instead of `type...
j
Is it possible to tell a
SerializersModule
to look for an attribute called
name
instead of
type
without registering a custom serializer?
I’m dealing with a json like that:
Copy code
"attributes": [
  {
    "name": "attribute1",
    "value": 22.68
  },
  {
    "name": "attribute2",
    "value": false
  },
  {
    "name": "attribute3",
    "value": "test"
  },
  ...
]
although… perhaps you want to use a https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-json/kotlinx.serialization.json/-json-transforming-serializer/index.html to transform it to
Copy code
"attributes": {
  "attribute1": 22.68,
  "attribute2", false,
  "attribute3", "test",
  ...
},
instead of going through polymorphic serialization?
j
I simplified a lot my json, each object has a lot more of specific attributes related to its type, so
@JsonClassDiscriminator("message_type")
is probably the way to go for me
and the list of attribute isn’t fix neither