Live data from Hacker News

Show HN: This website is valid JSON

webdatarender.com

41–50 of 240 posts

Re: Show HN: This website is valid JSON

#41
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!

This is super cool and clever. I’m working on a personal site where I’ve been trying to build in some unexpected fun. If I borrow from your technique I’ll be sure to credit you!

Thank you very much. Check the GitHub, the loader, basic render, and the website itself are there: https://github.com/webdatarender

Also, send me a link, I would love to check it out!

Re: Show HN: This website is valid JSON

#42
post #25

You know, I once had a resume powered by JSON. It was rendered to a PDF (and HTML) but the syntax was backed by JSON. This was years back and I shudder to even recall the idea. I didn't create the project mind you, it was some NPM package back when I was a fresh 'un who didn't have thoughts on using a billion subdependencies Anyway, I was nearly broke and when I went to apply for the benefit, I was asked for my resum…

Probably https://jsonresume.org

I have my resume defined using this schema, which is handy because it's supported enough that every few years when I actually need to update it, I can find a website (such as https://resumake.io) where I can just copy in the JSON and get a nicely formatted PDF out of it.

Re: Show HN: This website is valid JSON

#43
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 think Blizzard used to do this way back on their website.

Way back when, the WoW armory (web-based character, guild, etc lookup) used to use this. It was incredibly useful for third-party integration - who needs scraping when they serve you the data on a silver platter.

Re: Show HN: This website is valid JSON

#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 they'll just skip over your document till they find pieces of html

- the JS made by the author is the part that parses the json as json, and it uses the #render key as its metadata section

You can try opening a file like this to test for yourself to get a sense of just the browser-parsing part, test.html:

    {
        "test": "hello",
        "myHtml": "Hello World"
    }
I do however get this warning in FireFox so perhaps this is pretty fragile:

> The character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. When viewed in a differently-configured browser, this page will reload automatically. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

I'm guessing differently-configured means not in quirks mode? Does quirks mode just make the browser extra fault tolerant?

Re: Show HN: This website is valid JSON

#46
post #40
post #22

Earlier quoted context omitted.

Definitely your tooling is better incarnation of the idea, XSLT is kind of an abomination

I love XSLT in theory. It had the daring to say that the most frequently programmed thing that we do is just translate data structures of one shape into data structures of a slightly different shape, and it said “That is what I shall focus on, doing just that.” And the way that it produced that, by “just start writing your output document and insert XSLT when you finally need to loop or query the input” seemed quite…

Just setup a bijection between XML and s-expressions and XSLT becomes a Lisp.

Re: Show HN: This website is valid JSON

#48
I love this!

You could use this to syndicate blog posts, sort of like RSS, except each entry is JSON and could be viewed as it's own page rendered by it's own renderer (carried by a CDN and cached by the browser), or by the renderer of the users choice.

Re: Show HN: This website is valid JSON

#49
post #45

Isn't Reddit like this, in a way? You can append ".json" at the end and get the data for a page. Others can build their own UI on top of this, if they don't prefer the first party representation. https://www.reddit.com/r/pics/.json

If you go back to the web as a bunch of file servers, where every URL ended in the extension type of the document you wanted, this is what you get. Then MVC frameworks said "hey, if the URL represents some semantic aspect of the View, we can show off the power of MVC by letting users swap out the view by changing the extension!" And voila, some.com/url.html for HTML and some.com/url.xml for XML and, later, some.com/url.json for JSON

Most of the big MVC frameworks offered this out of the box at some point, which made life easier before dedicated RESTful APIs became a thing.

Re: Show HN: This website is valid JSON

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

In regards to the character encoding issue, I wonder if they could just move the #render to the top of the object by inserting it as the first property.
Post reply on HN