Expand description
Format-agnostic contract input and output: JSON and XML.
XML is treated as an alternative syntax for the same data model, not
as a second schema. Documents are transcoded to serde_json::Value
and then deserialized with the existing serde derives, so both formats
share one definition, one set of defaults and one set of validation
rules — and a new product supports both the moment it is added.
(Deriving XML directly is not an option here: the data model relies on
#[serde(flatten)], internally tagged enums and untagged enums, none of
which XML serde implementations support.)
§XML conventions
- Elements are object fields.
<strike_price>100</strike_price>becomes"strike_price": 100. - Attributes are object fields too, which reads naturally for the
tag of a tagged enum:
<discount_curve type="flat">is the same as"discount_curve": { "type": "flat", ... }. <item>children make an array.<tenors><item>0.5</item> <item>1.0</item></tenors>becomes"tenors": [0.5, 1.0], and a single<item>still yields a one-element array. Repeated non-itemsiblings also collapse into an array.- Scalars are inferred:
true/falsebecome booleans, anything parsing as a number becomes a number, an empty element becomes null, everything else stays a string (so2027-07-17andCare safe).
Enums§
Constants§
- ARRAY_
ITEM - Element name that marks array members in XML.
Functions§
- parse
- Parse a document into any deserializable type, in either format.
- parse_
value - Parse a document in either format into a
Value. - render_
results - Render a list of contract results in the requested format.
- render_
value - Render a single value in the requested format.
- strip_
nulls - Drop null object fields recursively.