|
|
|
|
|
by remexre
1878 days ago
|
|
In general, JSON Schemas are (wrongly, in my view...) validation-oriented rather than type-oriented (for notions of types that would be familiar to Haskell, Rust, or Common Lisp programmers). I think that schema in particular could be represented, though, as: enum Thing {
foo { foobar: String },
bar { foobar: Option<f32>, barbaz: String },
}
|
|
Also, JSON schemas allows you to encode semantics about the value not only their types:
That's something I like about Typescript's type system btw: It's still a string, in Rust you would need an enum and a deserializer from the string to the enum.