Live data from Hacker News

Show HN: This website is valid JSON

webdatarender.com

91–100 of 240 posts

Re: Show HN: This website is valid JSON

#91
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…

XSLT is the only way to do HTML templating on the client without using JS. I think that is valuable.

[deleted]

Re: Show HN: This website is valid JSON

#92
post #44

For those like me who needed a little help... I do not fully understand the browser rendering process (someone who does please chime in), but what I gather about how this is works is: - the content-type of the page is "text/html", so the browser is trying to render html - there is no special meaning of the #render key to the browser (again the browser doesn't know this is json) - browsers are very fault tolerant so t…

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.

Here's one that works without JavaScript, you curmudgeon:

    data:text/html;charset=utf-8,%7B%20%22foo%22%3A%20%22bar%22%2C%20%22baz%22%3A%20%5B%20%22qux%22%20%5D%2C%20%22%23render%22%3A%20%22%3Chtml%3E%3Cbody%3E%3Cdiv%20id%3Dcontent%3E%3Ch1%3EMy%20fancy%20document%3C%2Fh1%3E%3Cp%3EThis%20is%20a%20completely%20%26quot%3Bnormal%26quot%3B%20HTML%20document.%3C%2Fp%3E%3C%2Fdiv%3E%3Cstyle%3Ebody%20%7B%20visibility%3A%20hidden%3B%20%7D%20%23content%20%7B%20visibility%3A%20initial%3B%20position%3A%20absolute%3B%20top%3A%200%3B%20%7D%3C%2Fstyle%3E%3C%2Fbody%3E%3C%2Fhtml%3E%22%20%7D
You can paste this directly into your URL bar, and view source to see the valid JSON document.

Re: Show HN: This website is valid JSON

#93
post #21
post #16

This is an interesting technical hack, but I have to ask what problem this is aiming to address?

I created this tool with a very odd necessity: I hate animations and overlay ;). I would like to have access to the website data directly and build my own interface, but for this, I would have to have access to the information only. I know that the website could expose an API, but WDR feels much more natural and easy (try to do a `fetch` on the page and get the JSON instantly). Now that I have built and have played a…

Why not use content type headers, and have the html version request the json version after loading?

Re: Show HN: This website is valid JSON

#94

Wow, now we can write pages like { "content": [ ["html", {}, [["head", {}, []], ["body", {}, [["h1", { id: "main-header" }, [ "Welcome to my", ["span", { class: "red-text" }, ["PAGE"]]]], ["h2", { id: "sub-header" }, [ "It's so cool.", ["br", {}, nil], "Don't you think?"]]]]]]]};

This is pretty close to how ProseMirror, a rich-text editor, manages its content state.

Example of a schema: https://github.com/ProseMirror/prosemirror-schema-basic/blob...

Example of a document converted to JSON: https://tiptap.dev/export

Re: Show HN: This website is valid JSON

#95
post #2

Hello everyone, I created a simple script that allows a website to be a valid JSON and still be able to present the information on the browser. Any feedback is appreciated!

So you have to put the render part at the bottom? Most JSON serializers don't guarantee order in an object, so are you constructing this JSON by hand?

Re: Show HN: This website is valid JSON

#99
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…

> 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.

Re: Show HN: This website is valid JSON

#100
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…

I still have nightmares from learning XSLT. It's very cool, but also, very strange, if you come from a procedural language background. Also, XSLT is really given power by being mixed with XPath (which is procedural). I suspect that if I had known more about FP back when I learned it, I would have had an easier time. I wrote up a really long, painful post about XSLT, way back in the early 'oughts.

XSLT is mainly used to transform XML into XML. The resulting document doesn’t have to be XML, though. I remember being assigned a task of parsing and importing a large XML document into a MySQL database. This was supposed to be done on PHP. I kind of felt repulsed by the idea of writing the parser in PHP (it would have been horrible). So, I used XSLT to transform the document into CSV and then just imported it using LOAD DATA. Worked like a charm.
Post reply on HN