Skip to content

Commit

Permalink
Remove unnecessary case from annotation classes, consolidate `allowUn…
Browse files Browse the repository at this point in the history
…knownKeys` annotation (#606)

Binary incompatible, needs to be done in 4.x
  • Loading branch information
lihaoyi authored Jul 12, 2024
1 parent 05e1904 commit dde18ac
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions upickle/core/src/upickle/core/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ trait Config {
* un-intuitiveness and verbosity
*/
def optionsAsNulls: Boolean = true

/**
* Whether or not unknown keys when de-serializing case classes should be allowed.
* Defaults to `true`, but can be set to `false` to make the presence unknown keys
* raise an error
*/
def allowUnknownKeys: Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import upickle.core.{Abort, AbortException, ArrVisitor, NoOpVisitor, ObjVisitor,
* package to form the public API1
*/
trait CaseClassReadWriters extends upickle.core.Types{
def allowUnknownKeys: Boolean = true

abstract class CaseClassReader[V] extends SimpleReader[V] {
override def expectedMsg = "expected dictionary"

Expand Down
4 changes: 2 additions & 2 deletions upickle/implicits/src/upickle/implicits/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package upickle.implicits

import scala.annotation.StaticAnnotation

case class key(s: String) extends StaticAnnotation
case class allowUnknownKeys(b: Boolean) extends StaticAnnotation
class key(s: String) extends StaticAnnotation
class allowUnknownKeys(b: Boolean) extends StaticAnnotation

0 comments on commit dde18ac

Please sign in to comment.