Algostream_infrastructure_network.JsonOutbound JSON encoding.
Yojson was already a dependency, but only ever for inbound parsing — exchange frames and config files. There is not one to_yojson in the rest of the tree, and there is deliberately none added: lib/performance and lib/risk_management are pure and dependency-light, and teaching them to serialize would be new dependency surface on the two libraries least suited to it. Encoding lives here instead, reading the to_assoc accessors those layers already expose — the precedent Performance.Metrics.to_assoc set.
Yojson happily emits NaN and Infinity, which are not JSON and which every browser's JSON.parse rejects. Financial metrics produce both routinely — a Sharpe ratio over zero variance, a leverage ratio on an empty portfolio. float maps them to null so a single degenerate metric cannot make an entire response unparseable.
val float : float -> tFinite floats encode as numbers; NaN and infinities encode as null.
val int : int -> tval int64 : int64 -> tval string : string -> tval bool : bool -> tval of_assoc : (string * float) list -> t(string * float) list to an object, guarding each value.
val to_string : t -> stringval of_histogram_summary : Algostream_telemetry.Histogram.summary -> tval of_health_status : Algostream_telemetry.Health.status -> tval of_alert : Algostream_telemetry.Alert.t -> tval of_telemetry : Algostream_telemetry.Snapshot.t -> tval of_runtime_instance : Algostream_runtime.Snapshot.instance -> tval of_runtime : Algostream_runtime.Snapshot.t -> tval of_series : (int64 * float) array -> t(ts_ns, value) series, as [[ts, v], ...] — the shape the charting code consumes.
val error : string -> t