persistent to json
As of now, all longevity database back ends translate persistent objects in and out of some JSON variant. MongoDB uses BSON, whereas in Cassandra, the persistent object is stored in JSON form in one of the columns. The translation itself is quite straightforward:
- Persistent objects, persistent components, and key values are translated into JSON Objects.
- If a persistent component or a
KeyValbeing translated only has a single member, that member value is inlined, so that the JSON produced is whatever JSON the member value produces.
- Basic values translate directly into JSON
primitive types, with two exceptions:
Charsare translated into single-character strings.
- DateTimes are converted to UTC time zone before serializing to avoid ordering issues.
Optionsare omitted from the JSON.
Optionsare inlined, so that
Some(expr)will produce the same JSON as
Listsare translated into JSON arrays.