You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quite often I find myself in the need to manually create a codec for a certain data type or multiple different codecs for a single type.
For example, in one of our services we have a java.lang.enum that holds physical units from timeseries databases. This unit gets delivered by a 3rd-party system as e.g. "EUR/MWh" and we convert it to our UnitsEnum.EUR_PRO_MEGAWATTSTUNDE value
The enum type is used in the data classes that interact with the 3rd-party system, as well in the responses given out by our services. We do not want to have two enums containing the same information and map between them.
In Jsoniter-Scala this is straightforward, we simply created two codecs by hand with minimal boilerplate. Something similar should be possible with zio-json
Dependening if we're in the layer interacting with the 3rd-party service or in the layer serving our web-responses, we simply define one of these two codecs as implicit and the macros generating the responses pick them up, e.g.
Quite often I find myself in the need to manually create a codec for a certain data type or multiple different codecs for a single type.
For example, in one of our services we have a
java.lang.enum
that holds physical units from timeseries databases. This unit gets delivered by a 3rd-party system as e.g. "EUR/MWh
" and we convert it to ourUnitsEnum.EUR_PRO_MEGAWATTSTUNDE
valueThe enum type is used in the data classes that interact with the 3rd-party system, as well in the responses given out by our services. We do not want to have two enums containing the same information and map between them.
In Jsoniter-Scala this is straightforward, we simply created two codecs by hand with minimal boilerplate. Something similar should be possible with zio-json
Dependening if we're in the layer interacting with the 3rd-party service or in the layer serving our web-responses, we simply define one of these two codecs as implicit and the macros generating the responses pick them up, e.g.
The text was updated successfully, but these errors were encountered: