Expand description
Serialization module for converting external data formats to string values.
These functions convert data from external formats (JSON, MsgPack, Protobuf)
into string values ready for use with ExecutionPlan::with_values().
- null values are skipped (treated as “fact not provided”)
- JSON numbers, booleans, arrays, objects are converted to their string representation
§Example
ⓘ
use lemma::serialization::from_json;
let json = br#"{"discount": 21, "config": {"key": "value"}, "name": null}"#;
let values = from_json(json, &execution_plan)?;
// discount -> "21"
// config -> "{\"key\":\"value\"}"
// name -> skipped (null)
let plan = execution_plan.with_values(values, &limits)?;Functions§
- deserialize_
fact_ path_ set - Deserializes array of FactPath structures to HashSet
. - deserialize_
resolved_ fact_ value_ map - Deserializes from array of [FactPath, FactData] tuples.
- from_
json - Parse JSON to string values for use with ExecutionPlan::with_values().
- from_
msgpack - Convert MsgPack values to string values for use with ExecutionPlan::with_values().
- from_
protobuf - Convert Protobuf values to string values for use with ExecutionPlan::with_values().
- serialize_
fact_ path_ set - Serializes HashSet
as array of FactPath structures. - serialize_
resolved_ fact_ value_ map - Serializes HashMap<FactPath, FactData> as array of [FactPath, FactData] tuples.