3 ms·
Can we just get rid of HTML and replace it with JSON while we're at it?
by Patrick_Devine 12y ago
Can we just get rid of HTML and replace it with JSON while we're at it?
- mcintyre1994 12y agoJSON rendered with react Js using JSX feels to me like the future of html.
- scrollaway 12y agoI've heard that before... https://en.wikipedia.org/wiki/XSLT https://en.wikipedia.org/wiki/XSLT
- Argorak 12y agoIsn't the Blizzard website largely written in XML and XSLT? I can imagine quite a few scenarios where that can be a good approach.
- mcintyre1994 12y agoAn interesting example I came across is documenting an xml schema by converting it to xhtml. I think it goes without saying that Javascript and JSON make react a lot friendlier though.
- scrollaway 12y agoThe WoW Armory website used to be written in XSLT on top of a horrendeous java stack. It's commonly referred to as the badmory and was slow as all hells. It had a pure-html fallback (rendered serverside into html) for unsupported browsers. It's one of the worst pieces of web I've ever seen... and I've seen some stuff. It's no longer using all this, of course. They hired the guys from wowhead.com and had them redo the whole thing in a saner stack.
- byuu 12y agoI don't know if there's a proper name for this ability, but neither JSON nor YAML allow you to embed child tree nodes inside of node values. This ability requires named end tags. Example: <p>This is <b>bold</b> text.</p> "p": "This is ... uh ... nevermind." You could make a compelling argument that you shouldn't do this (separate block level and inline elements into separate encodings), but remember that even the relatively minor HTML->XHTML movement to put a bit of sanity into single-use tags like <br> -> <br/> failed miserably.
- Xophmeister 12y agoNodes have multiple children. In this case, you can split the <p>'s children into three: a "text node"; a <b> node; and another text node. You'd end up with something like this: { p: [ { text: 'This is' }, { b: { text: 'bold' }}, { text: 'text.'} ] } Not that I don't agree with you -- my suggestion is pretty messy and doesn't even go into how we'd deal with tag attributes -- but it's doable.
- JetSpiegel 12y agoThis has to be pre-processed somehow, if people don't like writing HTML by hand, consider writing that.
- byuu 12y agoYeah, and that's not really equivalent HTML either. That's more like: <p> <text>This is</text> <b><text>bold</text></b> <text>text.</text> </p> (which is a lot easier for a machine to parse, at least.) JSON and YAML are great for what they do: data serialization, but they're just not appropriate choices for text markup. You have to use the right tool for the job. There was a time when the industry wanted to cram 100% of everything into XML, and that gave us XSLT, XAML, SOAP, etc. We don't want to go back to that, either. Personally, I'm most fond of an extended Markdown syntax to replace HTML. But I'm not going to hold my breath waiting on web browser vendors to agree on such a syntax, so instead I have my HTTP server do the conversion to HTML for me. But if you had to force it into JSON, then I would suggest using a different markup for inline elements, eg: html body p: "This is [/italic/] text." p: "This is [[google.com => a hyperlink.]]"