-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude class discriminator #1487
Comments
You can skip the writing of the |
Can you provide example? |
val data = ChildClass("...")
Json.encodeToString<ParentClass>(data) // discriminator written
Json.encodeToString<ChildClass>(data) // discriminator omitted |
In my case, this will not suit |
What's your use case for excluding the discriminator? You won't be able to decode polymorphic data without it. |
Probably the other posted issue: #1486 (comment) In that specific use case, using |
@sandwwraith I don't need to decode this json. It goes to the server. The server does not accept unknown fields. Right now I forked the library and added a new field to the builder, so now I have two Json instances, one for the application that writes the class discriminator and the other for the api, which skips it when serializing. |
I'll close this because #1247 already mentions this use-case — feel free to continue the discussion there |
Right now in
Json { }
we cannot disable writeclassDiscriminator
. In source code i found that class discriminator can be ignored if we changewritePolymorphic boolean
insideencodePolymorphically
inStreamingJsonEncoder
. Can i somehow change it without fully fork your library and change all layers? Maybe somehow with extensionThe text was updated successfully, but these errors were encountered: