Live data from Hacker News

When XML Beats JSON: UI Layouts

engineering.instawork.com

101–110 of 274 posts

Re: When XML Beats JSON: UI Layouts

#101
post #84

Earlier quoted context omitted.

{ "type": "div", "children": [ "The ", { "type": "a", "attributes": { "href": " https://www.json.org/" }, "children": [ "JSON format" ] }, " was invented by ", { "type": "a", "children": [ "Douglas Crockford" ] } ] } I think I prefer the XML :-) Edit: I agree that tagged text is a clear win for XML - for pretty much everything else I'd go for JSON. Edit2: HN ate my formatting, but probably not a bad thing ;-)

["div", "The ", ["a", {"href": " https://www.json.org/" }, "JSON format"], " was invented by ", ["em", "Douglas Crockford"], "."]

that looks like the JSON documents in AWS's CloudFormation

Re: When XML Beats JSON: UI Layouts

#102

Earlier quoted context omitted.

Congrats on re-inventing frontend web development, I heard Facebook's hiring. This is one of the reasons people use frontend frameworks (besides state management).

Why the hostility? Should we not be open to exploring alternate ideas?

I should add that I'm not literally saying that we should do this. I assume smarter people than me have thought this through, and that there are good reasons why my proposal would be a bad idea. I'd be interested to know what those reasons are.

Re: When XML Beats JSON: UI Layouts

#103
post #84

Earlier quoted context omitted.

{ "type": "div", "children": [ "The ", { "type": "a", "attributes": { "href": " https://www.json.org/" }, "children": [ "JSON format" ] }, " was invented by ", { "type": "a", "children": [ "Douglas Crockford" ] } ] } I think I prefer the XML :-) Edit: I agree that tagged text is a clear win for XML - for pretty much everything else I'd go for JSON. Edit2: HN ate my formatting, but probably not a bad thing ;-)

["div", "The ", ["a", {"href": " https://www.json.org/" }, "JSON format"], " was invented by ", ["em", "Douglas Crockford"], "."]

Quite readable but it's a hell to parse. The first argument is the name of the element, but what is the second one? If it is a string or an array, it's the first child, but if it's an object, it's the attribute set?

Re: When XML Beats JSON: UI Layouts

#104
post #64
post #41

What XML is also very good at is: representing tagged text, what is called "mixed content" in XML terminology. Just try to write the JSON equivalent of: The JSON format was invented by Douglas Crockford . If your document consists mainly in losely structured text with some annotation, you better use XML.

So Jupyter Notebooks should be XML instead of JSON. Right ?

AFAIK notebooks are a list of cells, each cell consisting in text, but there is no meta information within the cells, so JSON looks OK there.

Re: When XML Beats JSON: UI Layouts

#105
post #36

The main reason that I use XML (occasionally) is because of XML Schema. It's a very precise data description that can be semantically verified. Otherwise, I try to use JSON, where possible, because I am not a masochist.

Does https://json-schema.org/ not work for you?

It would, if anyone used it.

The thing about XML Schema, is that it is completely "baked into" pretty much every tool and library out there, so you can do "on-the-fly" runtime validation.

JSON is really about minimizing text. It works really well for this.

Another issue, is that JSON doesn't have comments, so it can be difficult to annotate a JSON file.

Re: When XML Beats JSON: UI Layouts

#106
post #62
post #50

Earlier quoted context omitted.

Well, for instance, let's take the HTML code of your comment (which happens to be a valid XML document): I have yet to read anything that convinces me that XML is good for anything . Just because XML in certain cases is less bad than some other cherry-picked technology, doesn't mean that there aren't other better options. See also Erik Naggum's legendary rant: https://www.schnada.de/grap…

Side note: You've overdone the character entities a bit more than necessary.

I know, not my fault, I just copy/pasted the actual source code of the page while I was commenting.

Re: When XML Beats JSON: UI Layouts

#107

I don't disagree that JSON is better than XML for their "list" example,and that XML is better than JSON for their "UI layout" example. BUT: > This means there’s no officially supported way to represent the list of movies in an element attribute. We can hack this by encoding the list into an attribute using a comma delimiter: So, that's because you're doing it wrong. XML has NO PROBLEM with hieararchy, REALLY. Of COUR…

You should have read the next paragraph. They do use that as an example

    
      
        Michael
        Scott
        
          Diehard
          Threat Level Midnight
        
      

Re: When XML Beats JSON: UI Layouts

#108
post #84

Earlier quoted context omitted.

["div", "The ", ["a", {"href": " https://www.json.org/" }, "JSON format"], " was invented by ", ["em", "Douglas Crockford"], "."]

Quite readable but it's a hell to parse. The first argument is the name of the element, but what is the second one? If it is a string or an array, it's the first child, but if it's an object, it's the attribute set?

What if text were quoted?

Re: When XML Beats JSON: UI Layouts

#109

One thing I really miss when working on JSON vs XML data are comments. A workaround is to make the comment a valid string in the data, but still not as good as having the ability to comment an arbitrary line.

XML has comments. They are the same as HTML comments.

Re: When XML Beats JSON: UI Layouts

#110

Earlier quoted context omitted.

Why the hostility? Should we not be open to exploring alternate ideas?

I should add that I'm not literally saying that we should do this. I assume smarter people than me have thought this through, and that there are good reasons why my proposal would be a bad idea. I'd be interested to know what those reasons are.

I am not intentionally being hostile, just pointing out that your stated deficiency is the one of the reasons why people migrated to component-style frameworks. It's an affirmation of your comment's validity not a criticism.
Post reply on HN