Live data from Hacker News

Show HN: This website is valid JSON

webdatarender.com

141–150 of 240 posts

Re: Show HN: This website is valid JSON

#141
post #99

Earlier quoted context omitted.

> Apparently web standards folks in the early 2000s thought the future was XML all the way down. It should have been, but just like the masses rejected LISP for its parens, the masses rejected XML for the closing tag. We could have avoided PHP and the zoo of MVC frameworks.

If only XML wasn't so damn complicated , it might have had a chance. People love to point at close tags, but there's a long list of more serious problems. External entities, namespaces within namespaces, CDATA, namespaces that confusingly look exactly like URLs, but aren't, parser vulnerabilities.

The way XML does namespaces is one of the best things about it - you can host any XML dialect within another, with no name clashes, and without losing the schema identity of embedded parts. Infinite data composability, subject only to the constraints placed by schema authors. And namespaces are URIs, so they can be URLs.

The bad smell was mostly coming from all the things inherited from SGML - CDATA, entities etc. Although I would also add that separation into elements and attributes is not a particularly convenient way to model many things; it mixes up differences that should really be orthogonal (ordered/unordered, atomic/composite etc).

Re: Show HN: This website is valid JSON

#142

Earlier quoted context omitted.

You are correct. It's a silly hack. Just because it happens to work doesn't make it a good idea. Turn off JavaScript and you just get JSON text.

I have created a similar silly hack where you can just write markdown directly: # Markdown header ## Subheader ### Section header 1. Numbered 1. List - Unordered - List [//]: # ( var doc = document.children[0].textContent.split('\n'); md = doc.slice(0, doc.length - 1).join("\n"); document.body.innerHTML = marked(md); That last line has varying degrees of invisibility in different markdown viewers I looked at. Obvious…

this reminds me of https://casual-effects.com/markdeep/

Re: Show HN: This website is valid JSON

#143

Earlier quoted context omitted.

The page says: > I'm creating a blog platform using this concept. Yeah, please don’t; this is an abomination that’s fun for demonstrating and teaching how these things work, but should absolutely never be used in reality. You could use this as your data model foundation upon which to build a generator , but you should never under any circumstances actually serve this stuff.

It's kind of the author's problem and not ours. If they want to figure out how to make a quirks-mode page work correctly, be my guest. It will just be unnecessarily painful.

Maybe browsers should artifically delay the rendering of pages in the quirks-mode to create incentive for website creators to use proper formats/techniques.

I can imagine the author had their fun, I also had fun reading the article, but I don't think this is leading to an accessible internet.

Re: Show HN: This website is valid JSON

#144
post #88

Earlier quoted context omitted.

You are correct. It's a silly hack. Just because it happens to work doesn't make it a good idea. Turn off JavaScript and you just get JSON text.

> Just because it happens to work doesn't make it a good idea. An oft-unheard voice of wisdom and sane engineering practices speaks. Hark, ye mortals.

This but unironically.

Re: Show HN: This website is valid JSON

#145
post #17
post #10

This is a really cool hack. > The JSON must contain only pure information without any concern about design or markup. Wellll.. I mean the json has markdown syntax in it. That's a lot nicer than html tags for markup, but it's still markup. In case anyone reading hasn't seen it before, browsers have a thing called XSLT built into them that does something similar for XML documents. You serve up your data as XML, add a t…

Yeah, I thought about using XML/XSLT too, but I think JSON would be more aligned with today's tools. Also, the render could be written in React or Vue, and add all the functionalities of a modern web app, for example, not just HTML.

It depends on which tools you're thinking about. When it comes to web browsers, they can process XML+XSLT (to produce and render HTML output) out of the box. On the other hand, it looks like the hack you're using here to make the JS renderer auto-load is not really valid HTML (as a whole)?

Re: Show HN: This website is valid JSON

#150

Earlier quoted context omitted.

The page says: > I'm creating a blog platform using this concept. Yeah, please don’t; this is an abomination that’s fun for demonstrating and teaching how these things work, but should absolutely never be used in reality. You could use this as your data model foundation upon which to build a generator , but you should never under any circumstances actually serve this stuff.

It's kind of the author's problem and not ours. If they want to figure out how to make a quirks-mode page work correctly, be my guest. It will just be unnecessarily painful.

Quirks mode is not the only problem of this approach.

It may not significantly affect users of modern browsers in their default configuration with good internet connections, but it does affect plenty of other things.

You want to parse things in the document? Now you need a whole different suite of tools from the usual tools you use. Your library that parses all the meta tags, identifies the content, &c. is now useless. Now you need either a full JavaScript execution environment, or a JSON parser instead of an HTML parser (and that JSON has completely lost the semantics that HTML provides, so you can’t query things like “document title” or “meta description”).

You have JavaScript disabled? Here, have a mess that, well, it’s better than most client-side rendering things in that the content is still probably there, rather than the screen just being blank, but there are reasons why you should always prefer server-side rendering for things like blogs.

You have a slow or unreliable internet connection? Now the page is taking longer to load, and until the JavaScript loads, the page is empty—and it may fail to load.

I object to people doing things like this as more than a fun technical demonstration because it does harm some users.

Post reply on HN