Live data from Hacker News

Show HN: This website is valid JSON

webdatarender.com

81–90 of 240 posts

Re: Show HN: This website is valid JSON

#81
post #56
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

The same could be achieved by having the server return different views of the data for different HTTP Accept headers, although not as convenient as appending a file extension. I once did this to interpolate REST API responses into dedicated HTML templates if requested with Accept: text/html, which made exploring the API in the browser more enjoyable.

[deleted]

Re: Show HN: This website is valid JSON

#82
post #75
post #26

Earlier quoted context omitted.

Yes, this is a good catch. The reason for this is the basic render that I created is generic, and it is not what you should do to render your JSON. The render should fit perfectly with the JSON. The basic render is just for a quick start. For example, the basic render "# Title" creates an h1 header, but if you created the render, you know the internal schema of the JSON, so you can use the correct HTML element for th…

"try not to use markup on the JSON, because this would make it difficult for others to consume your website with JSON." Since there is no standard for representing rich text in JSON, if you want rich text, this is simply an unavoidable problem. At least Markdown is semi-standard and people can get libraries for it. Embedded HTML would also work. Defining an ad-hoc rich text embedded would be worse.

You are correct. Sometimes, some markup is inevitable. You can try to break down the information to render separately, but it is not always possible. So I think a little bit of markdown would be an acceptable compromise.

Re: Show HN: This website is valid JSON

#84

The json.org description of an "object" is: > An object is an unordered set of name/value pairs. But this site seems to be assuming that the key/value pairs are parsed in their original ordering for everything to display properly. Is it safe to assume JavaScript will always parse the keys in order?

The website uses the basic render, that is just a start to make it easy to create a page quickly. But ideally, you create a custom render, that will not depend on the order.

Re: Show HN: This website is valid JSON

#86
post #83

RIP SEO

Not really, Google and Bing will read the page correctly with Javascript. Check the page insight: https://developers.google.com/speed/pagespeed/insights/?url=...

But it would be even better if they could get the information directly on JSON. So much carbon saved ;)

Re: Show HN: This website is valid JSON

#87
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

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

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

Re: Show HN: This website is valid JSON

#89
post #57

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 actually the exact opposite of why I have created WDR. The JSON is supposed to be only pure data. All the markup should be inside the render.

Don't worry mate, just mucking about.

https://en.wikipedia.org/wiki/SXML

Re: Show HN: This website is valid JSON

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

[deleted]
Post reply on HN