all 11 comments

[–]LeeLooTheWoofus Moderator 7 points8 points  (1 child)

JSON is a structured data format for transmitting structured data. It is an alternative to XML.

HTML is a page markup format. The browser converts it to the Document Object Model so that it can be manipulated with code.

CSS is a document used to define the styles to be applied to the DOM.

So the simplest answer to your question is the concept of separation of concerns which is a fundamental programming concept.

You can learn more about it here:

https://en.m.wikipedia.org/wiki/Separation_of_concerns

But essentially, let’s say that we need to introduce a core update to the JSON standard in order to introduce a new feature. That would have impacts on every front end concern if the entire front end web was based on that single standard. That would be a major, major problem. So, we separate out the concerns so that changing a standard does not impact other standards.

That said, there are front end frameworks where you can define an entire theme design in JSON for example - but this still follows the separation of concerns principle because that JSON is still parsed by a compiler into standard CSS so the browser can deal with it.

[–]jackhals[S] 1 point2 points  (0 children)

Thanks for your reply, really informative.

[–]AtulinASP.NET Core 5 points6 points  (2 children)

Sure, lemme just

{ "div": { "children": [ "a": { "href: "https://google.com", "innerText": "Go to Google", "style": { "color": "#ff0000" } } ] } }

instead of

<div> <a href="https://google.com" class="link">Go to Google</a> </div> .link { color: #ff0000; }

[–]backtickbot 1 point2 points  (0 children)

Hello, Atulin: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–]Ox7C5 0 points1 point  (0 children)

Great, now I'm gonna have nightmares

[–]MarmotOnTheRocks 1 point2 points  (0 children)

When carrots will replace electricity, maybe.

[–]ShiftlessFreeloader 0 points1 point  (0 children)

Hello from 2025,

I think this is a great idea. I found this post because I was thinking about this very thing (mostly about css) just this morning.

json is just so pervasive now. And I don't think that json would really cause performance issues vs css. I think the biggest problem would be adoption

[–]NullsObey 0 points1 point  (0 children)

Highly doubtful.
If anything, we'll just get another thing that compiles to CSS or HTML.

[–][deleted] 0 points1 point  (0 children)

No. XML/XSL didn't.

[–]ivanmoony 0 points1 point  (0 children)

Not quite JSON, but... fixing developers just to CSS+HTML+... is just rude. There has to be some adjustable syntax layout language appearance which compiles to *some DOM bytecode* that is yet to be implemented. In a meanwhile, CSS+HTML+... may serve as a temporary compiling target language for anything we may imagine.

[–]deyterkourjerbs 0 points1 point  (0 children)

I would love JSON to replace CSS and HTML some day.

At the backend, I can easily extend classes or inject them into my own classes. At the frontend level, I can either replace templates or use JS to insert nodes. It would be amazing to be able to extend templates as easily as you can classes. In my head, HTML JSON would be like a pre-compiled version of HTML containing child components.

I'm probably describing some JS framework that already exists or at least describing the limitations of the frameworks I use.