#[sark_gen::json] derives compact JSON encode/decode for named structs.
Fields default to scalars (u64, bool, Bytes<Retained>, Option<T>). Two
#[field(...)] attributes compose nested documents:
#[field(nested)]on a field whose type is another#[sark_gen::json]struct emits"key":{...}using that type's own encoder.#[field(seq)]on aVec<Bytes<Retained>>emits a JSON string array"key":["a","b"]; combine withnested(#[field(seq, nested)]) on aVec<T>of json structs to emit an array of objects"key":[{...},{...}].
Empty vectors encode as []. nested/seq are not supported with exact.
#[sark_gen::json(ordered)]
struct Rating { score: u64, count: u64 }
#[sark_gen::json(ordered)]
struct Item {
id: u64,
#[field(seq)] tags: Vec<Bytes<Retained>>,
#[field(nested)] rating: Rating,
}
#[sark_gen::json(ordered)]
struct ItemsResponse {
#[field(seq, nested)] items: Vec<Item>,
count: u64,
}