From what I can see, your JSON still contains "style" information in the form of Markdown. So this doesn't really separate information from design. If we're going to accept Makrdown as minimal styling, why not just use regular HTML. Which technically is already separating between information (HTML markup) and design (CSS).
> 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?
> Is it safe to assume JavaScript will always parse the keys in order?
Technically, no. Functionally, probably yes. Any browser vendor that decides to muck with the current status quo would likely break enough code to be a non-starter.
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.
And then JSON.parse is defined as doing the obvious and only sane thing, setting each property as it goes. Consequently, so long as your keys are not numeric, yes, JavaScript guarantees that it will all be in order. But that’s for JavaScript. It is incorrect to treat JSON objects as ordered, because various libraries in various languages will discard the order for various reasons (e.g. efficiency, DoS resistance), since it is defined as being not significant. If you care about the order of things, use an array instead.
At my previous job I worked at a whole UI framework (server side) based on XSLT transformations. We built kind of abstraction layer on top of ExtJS,HighCharts and some 3D rendering lib at that time. It was hell to debug anything in there because the output was HTML sprinkled with JavaScript and it was not always easy to identify what part of XML and XSLT was responsible for given part of output. It was quite successfully used in one internal ERP mashup app that sucked data out of some SAP system.
Learning XSLT actually helped me understand C++ templates (big aha moment).
So we had this XSLT monster crunching on XML files but what we really needed was JSX which probably wasn't a thing until few years into the project.
Comments (229) 60 threads
Earlier commentsCool, but why?
> 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?
Technically, no. Functionally, probably yes.
Any browser vendor that decides to muck with the current status quo would likely break enough code to be a non-starter.
And then JSON.parse is defined as doing the obvious and only sane thing, setting each property as it goes.
Consequently, so long as your keys are not numeric, yes, JavaScript guarantees that it will all be in order.
But that’s for JavaScript. It is incorrect to treat JSON objects as ordered, because various libraries in various languages will discard the order for various reasons (e.g. efficiency, DoS resistance), since it is defined as being not significant. If you care about the order of things, use an array instead.
All comments shown.
Couldn't load more comments. Check your connection and try again.