Skip to content

Commit

Permalink
JSON: Fix mutable classDiscriminatorMode in config, and mark experi…
Browse files Browse the repository at this point in the history
…mental in builder (#2680)

Since this is a new feature, it should have been added as experimental to the builder, but it wasn't done properly. 

Deprecate mutable `classDiscriminatorMode` in `JsonConfiguration` — vars are not needed there.
  • Loading branch information
BenWoodworth authored May 28, 2024
1 parent 385c97d commit c487e78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ public class JsonBuilder internal constructor(json: Json) {
* Other modes are generally intended to produce JSON for consumption by third-party libraries,
* therefore, this setting does not affect the deserialization process.
*/
@ExperimentalSerializationApi
public var classDiscriminatorMode: ClassDiscriminatorMode = json.configuration.classDiscriminatorMode

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class JsonConfiguration @OptIn(ExperimentalSerializationApi::class) inter
@ExperimentalSerializationApi
public val allowComments: Boolean = false,
@ExperimentalSerializationApi
@set:Deprecated(
"JsonConfiguration is not meant to be mutable, and will be made read-only in a future release. " +
"The `Json(from = ...) {}` copy builder should be used instead.",
level = DeprecationLevel.ERROR
)
public var classDiscriminatorMode: ClassDiscriminatorMode = ClassDiscriminatorMode.POLYMORPHIC,
) {

Expand Down

0 comments on commit c487e78

Please sign in to comment.