Hey! Great lib! Does it already support this use case?
struct StateHolder: Codable {
let state: State
enum State: Codable {
case on(On)
case off(Off)
struct On: Codable {
let onOnlyProperty: String
}
struct Off: Codable {
let offOnlyProperty: String
}
}
}
when I JSON encode StateHolder(state: .on(.init(onOnlyProperty: "On!"))) Swift produces:
{
"state" : {
"on" : {
"_0" : {
"onOnlyProperty": "On!"
}
}
}
}
Or using .off respectively:
{
"state" : {
"off" : {
"_0" : {
"offOnlyProperty": "Off!"
}
}
}
}
Which is... well I think that was strange design decision by SE-0295.
I always manually change this to:
{
"state" : {
"discriminator": "on",
"on" : {
"onOnlyProperty": "On!"
}
}
}
Is this support by the lib? Or something you would consider adding?
Hey! Great lib! Does it already support this use case?
when I JSON encode
StateHolder(state: .on(.init(onOnlyProperty: "On!")))Swift produces:{ "state" : { "on" : { "_0" : { "onOnlyProperty": "On!" } } } }Or using
.offrespectively:{ "state" : { "off" : { "_0" : { "offOnlyProperty": "Off!" } } } }Which is... well I think that was strange design decision by SE-0295.
I always manually change this to:
{ "state" : { "discriminator": "on", "on" : { "onOnlyProperty": "On!" } } }Is this support by the lib? Or something you would consider adding?