shorn: your Zod schema already describes the payload, so why send the keys? #6375
Replies: 1 comment
|
Hi @ChiChuRita! I'm Dosu and I'm helping the Zod team. shorn sounds like a really clever idea — using the schema as the wire format is an elegant reuse of something you're already paying for. On your stability question: Here's what I can tell you about the specific keywords you depend on:
What has changed recently: v4.4.0 shipped a fix where Practical advice: Pin to a specific For the most authoritative answer on stability guarantees, you'd want to hear from @colinhacks directly — I'm not aware of any explicit written promise on To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Uh oh!
There was an error while loading. Please reload this page.
I built shorn. It uses the Zod schema you already have as a binary wire format. Both sides have the schema, so field names never go in the payload.
It's also faster. JSON has to write every key and parse it back out again. shorn skips that work entirely, so it's up to 6.2x faster to encode and 14.5x to decode in my benchmarks. The saving comes from the schema, not from compression, so there's no CPU cost to pay for it.
No IDL, no codegen, no second schema. It reads validation through Standard Schema and structure through Standard JSON Schema.
Playground: https://shorn.dev
One question, since I depend on it: how stable is the
toJSONSchemaoutput? I pick encodings from the emitted keywords.minimumorexclusiveMinimumgives an unsigned varint,prefixItemsmeans a tuple,anyOfandoneOfmean a union. If those change shape, saved payloads stop decoding. I checked #6339 and my bytes are identical either way. The docs markfromJSONSchemaexperimental but say nothing abouttoJSONSchema.All reactions