5 ms·
I'll be one of the few positive voices here, I guess. JSON Schema is pretty good. It's a relatively simple, extensible, pragmatic specification that supports v
by atombender 5y ago
I'll be one of the few positive voices here, I guess.
JSON Schema is pretty good. It's a relatively simple, extensible, pragmatic specification that supports validating the kinds of data that JSON can express.
XML was killed by complexity, same as lots of technologies that preceded it, such as CORBA and SOAP. Developers don't like complexity. W3C tried to build an enormously complicated ecosystem of tools on top of XML. The specifications for XML Schema, WSDL, XSLT, etc. were gigantic. XML Schema and WSDL are both so big they are split into multiple parts. XSLT 3.0 is maybe 500 pages when printed. Many of these originated in the wrong sort of place, designed by committee and from inside big enterprises like IBM, rather than being adopted from evolving practices.
With XML out of the way, we still need a way to represent structured data, and it turns out JSON is pretty good for that. JSON has problems, but its simplicity is what lead to it becoming so prevalent in the first place. Now, we also need a way to define the structure and format of that data, and JSON Schema is pretty good for that. I think JSON Schema could have been a bit simpler, but it's still nowhere near to making the same mistakes as XML Schema.
- arethuza 5y agoStrongly agree - I've worked with ONC RPC, CORBA, SOAP, XML & XSD, XSLT etc. and I much prefer the relatively straightforward nature of JSON and JSON Schema. Yes it's not perfect - but for me it is more than good enough. Edit: Of course, there is no direct equivalent of XSLT in the JSON world - which pretty much counts as a feature to me.
- lolive 5y agoNor XPath.
- arethuza 5y agoI think XPath is actually one of the nicer bits of the XML universe - there is a JSON equivalent in JSONPath that I have used a bit.
- espadrine 5y agoOne thing I am wondering is whether the protobuf folks have a better development environment overall, or a worse one. Is the schema-to-self-validating-serialization-code approach going to win just as JSON won over XML?
- SV_BubbleTime 5y agoThis is what I was thinking, but no, skeptical. Protobufs are far more efficient, but dump the human readability for the data transfer, and that is where the logging and debugging happen quite a bit. As to code generation, if you use someone’s package for confirm_my_schema(thisjson) isn’t that basically code generation just moved somewhere else?
- dnautics 5y agonot all jsonschema validators are codegen/macros, so some of them are relatively unperformant and come with a lot of code baggage.
- Simplicitas 5y ago"[humans] don't like complexity"
- noworld 5y agoSo what makes JSON Schema better is that nobody will "build an enormous ecosystem of tools on top" of it?
- Bombthecat 5y agoYou don't need to?
- lolive 5y agoIt depends the (complexity of the) JSON schema to mainpulate.
- indymike 5y ago> Developers don't like complexity. Judging by the code that is in front of me right now, I'm pretty sure they really do like it... or at least make lots of it.
- shados 5y agoThey like to produce complexity, else they get bored while writing the code. But they don't like OTHER developer's complexity.
- jbverschoor 5y agoYeah they (including younger me) loved abstractions and complexity I wrote or I read about. But it’s complex and difficult to grasp, so it’s not fun when you have to get into someone else’s mind, or even to get back into your own thinking after period of a sense of that project/architecture
- lolive 5y agoThe rule is "K.I.S.S (and add more RAM !!!)"
- shados 5y agoMost new software devs go through that phase. A few decades ago, it was about the Gang of 4 design patterns. We were all reading that book and then looking for every possible place we could implement those patterns, even when they made absolutely no sense. I'm so sorry for the teams I worked with in those days. The worse is I felt the folks around me were worse devs for not doing the same. It's so embarassing in hindsight.
- DrBazza 5y ago"If I had more time I would have written a shorter letter" (Pascal, apparently).
- onionisafruit 5y agoThere’s a crude expression about smells and feces that applies here. I used to struggle to understand why other people didn’t like using all the clever abstractions I came up with. I felt unappreciated and thought I needed to learn how to communicate better. It turns out I was communicating just fine. What I needed to learn was how to accept feedback.
- shados 5y agoThis. Back in the XML days, I had to spend way to long reading XSLT and WSDL specs just to do basic things. JSON Schema takes 15 minutes to learn and it's a heck of a lot better than writing my own validator.
- kords 5y agoI remember I was enjoying XSLT; I used it to create templates and, in the end, valid XHTML pages. I thought that's the future.
- dehrmann 5y agoIt is a functional language, and the cool kids are really into those.
- kiliancs 5y agoAt some point I made a news-articles site and I took that approach rather than databases: the owner would write XML files for each article that would be pretty simple: e.g. with tags like `title`, `image` (left, right, hero)`, some asides and some basic formatting for the body of the article, and XSLT, templates and CSS would make it a proper page. All the magic happened in the browser. I still think that's pretty cool.
- shados 5y agoThat's pretty much what it was designed to do. You could push it pretty far too. Relational databases at the time all implemented XML types, so you could have XML all the way down, and XSLT is how you'd go from point A to point B. But in the end, simpler alternatives prevailed.
- mstade 5y ago> I think JSON Schema could have been a bit simpler, but it's still nowhere near to making the same mistakes as XML Schema. Agree with every single one of your points, and this in particular. Thankfully, there are some heroes out there developing excellent tooling to make working with JSON schema easier. I've been making good use of Ajv[1], and highly recommend it to anyone having to deal with JSON payloads and schemas in a javascript environment. (I'm not affiliated with Ajv in any way, just happy with it.) Working without a schema is much faster when getting started, obviously, but once things solidify in my experience a schema will help more than it costs and excellent tooling goes a long way in easing that transition from schema-less POCs to stable high quality implementations. [1]: https://ajv.js.org https://ajv.js.org
- dnautics 5y agoI used to resent the changes between the draft JSONSchema, but on reflection, almost all of them have been, IMO, extremely well chosen.
- andyjohnson0 5y ago> Developers don't like complexity. This may be true, but they also can't resist it's temptation. As long as we build tools that are composable, developers will continue to build complexity on top of them. I fear that json's fate is sealed.