4 ms·
Is the image/jpeg media type "typesafe"? How is using, for example, JSON Schema to define your types any better or worse than a "proto" file that requires a co
by rswail 4y ago
Is the image/jpeg media type "typesafe"?
How is using, for example, JSON Schema to define your types any better or worse than a "proto" file that requires a compiler, a parser, and a client and server library?
- jrsj 4y agoThe difference is really that with something like protobuf type safety is built in & with JSON it's an afterthought. With JSON Schema or OpenAPI it's on you to keep things in sync with your API & there's often a significant amount of work that comes along with that too. There's many tradeoffs of course, it's not like dealing with proto files is painless either.
- rswail 4y agoWhat you're actually saying is that when you use the standard language bindings for a protobuf parser, the type safety is as built in as your language. JSON has a limited set of types. There is object, array, string, number, boolean, and null. That's it. JSON Schema adds to that by providing definitions of types that build on those basic JSON types.