Open Andrapyre opened 1 month ago
@jdegoes , while this is waiting for upstream dependencies to upgrade to Scala Native 0.5.x
, could you review the current implementation? I've tried to preserve the benefits of Magnolia's pre-computation as much as possible, while still offering support for a wide array of default values that need to be computed in real time.
Description
This PR closes https://github.com/zio/zio-json/issues/1055 and, in the process, updates
zio-json
to the Scala Native0.5.x
series (necessary because this requires multiple PRs to Magnolia and Magnolia is already on the0.5.x
series). The solution does the following things:It provides out-of-the-box support for random generators which are not time-based, as well as support for all classes that extend
java.time.temporal.Temporal
- all of the following:It introduces a
@jsonAlwaysEvaluateDefault
annotation to force evaluation of the default parameter every time json is decoded (especially relevant for timestamp values coming from 3rd party libs, e.g.org.joda.time
).The result is that users can implement the following case class and expect the results for each parameter as described in the comments:
External dependencies
Several external dependencies need to be closed before this will build in Github Actions:
0.5.x
. This can be started once upstream dependencies are upgraded. https://github.com/zio/zio/issues/8786Thescala-java-time
lib needs to be upgraded to Scala Native0.5.x
. https://github.com/cquiroz/scala-java-time/pull/508One PR needs to be merged into the Magnolia Scala2.x
series. https://github.com/softwaremill/magnolia/pull/533One PR needs to be merged into the Magnolia Scala3.x
series. https://github.com/softwaremill/magnolia/pull/534/claim #1055