Nothing
, translates well to null
.
For other custom types, reaching for a codec library is a good idea. As you will need to have metadata in your json to identify the variants in your custom types. The codec libraries take care of that e.g. they add a property like __tag__
or something similar.
However, maybe rethink storing those directly, as your custom types in your app can get out of sync with your stored data very quickly. You would have to version your custom types and deal with that. I think these codec libs are fine for transmitting the data. But you probably don’t want to store it as is.