com-lihaoyi / upickle

uPickle: a simple, fast, dependency-free JSON & Binary (MessagePack) serialization library for Scala
https://com-lihaoyi.github.io/upickle
MIT License
707 stars 158 forks source link

Add typed Readers and Writers for Java boxed primitives #462

Closed lihaoyi closed 1 year ago

lihaoyi commented 1 year ago

The current readers and writers already handle null correctly:

  1. Readers https://github.com/com-lihaoyi/upickle/blob/7e469da3c721872e482a505cd71119537b2a2f20/core/src/upickle/core/SimpleVisitor.scala#L9
  2. Writers https://github.com/com-lihaoyi/upickle/blob/7e469da3c721872e482a505cd71119537b2a2f20/core/src/upickle/core/Types.scala#L129

except readers cast it to e.g. 0: Int when returning it. By casting the readers to Reader[java.lang.Integer], this allows the nulls to remain nulls.