4 ms·
Ever tried writing a JSON schema? It's horrific. I'd rather use Protobufs or Flatbuffers for specification and then rely on their built-in JSON serialisations.
by nly 9y ago
Ever tried writing a JSON schema? It's horrific.
I'd rather use Protobufs or Flatbuffers for specification and then rely on their built-in JSON serialisations.
- user5994461 9y agoI wrote quite a few. I wouldn't call that horrific at all.
- zbentley 9y agoI don't think JSON schema is bad at all, for what it is. Remember that the more modern binary protocols like protobuf/etc. don't serve the same niche as JSON schema at all: JSON schema validates external documents; i.e. you take a schema and make sure a document complies with it. Protobuf/flatbuffers/etc. validate internal documents, as they are encoded or decoded. If that's all you need, then the schema definitions for those products will be much friendlier than JSON-schema, but that's comparing non-equivalent things. Another, minor quibble is that a lot of the schema-validation code in e.g. protobuf or Thrift is often generated by the framework, and the generated code can be quite hairy or confusing. There exist code generators for JSON schema as well, but writing a JSON schema by hand isn't comparable to, say, generating code from the Thrift IDL.
- nly 9y agoApache Avro follows a rather nice hybrid approach where the schema is required for decode (it's an untagged binary encoding) but the schema can loaded dynamically in to the library.