Model a tagged stream of model events with serde internally tagged enums
Map a JSON event stream with a "type" field onto a Rust enum using #[serde(tag = "type")], handle unknown event types, and see why tuple variants fail to compile.
Topic · 8 stories
8 stories tagged json on AI Tamer, newest first.
Map a JSON event stream with a "type" field onto a Rust enum using #[serde(tag = "type")], handle unknown event types, and see why tuple variants fail to compile.
If your agent logs one JSON object per line, five short jq filters turn that log into answers: which tool calls failed, which tools fail most, which steps were slowest, and how much time the logged calls span.
A valid JSON integer may lose precision when parsed as a JavaScript Number. Decimal strings keep opaque IDs stable across runtimes.
An older proto3 service can carry a newer binary field through unchanged message handling, but a JSON conversion or field-by-field rebuild can drop it.
Serde checks untagged enum variants in order. When two variants accept the same JSON object, their order decides which one the program receives.
A repeated JSON object name can produce different results in different parsers. Here is how to spot the problem and reject it.
A JSON Pointer can resolve successfully while selecting the wrong field. Escape each member name before building the pointer.
How to handle a model response that arrives in pieces. It covers server-sent events, partial JSON, user cancellation, and what is safe to store.