5 ms·
I literally don't get why JSON is bad: [{row1}, {row2}, {row3}] The fact that it can do more is in no way a negative. Can even make a limited JSON parser with
by Justsignedup 4y ago
I literally don't get why JSON is bad:
[{row1}, {row2}, {row3}]
The fact that it can do more is in no way a negative. Can even make a limited JSON parser with reduced capabilities. And with JSON can do more definitions like header names vs column names vs just arrays of arrays.
- orasis 4y agoA JSON array doesn't allow easily appending a row. JSONLines is a bit better.
- LeonB 4y agoI remember my annoyance at XML that you couldn’t simply append a row, due to the closing tag. I think there was some off-spec dialog called something like “appendable xml” (only snappier) that said the closing tag of the root element was optional, but it was clearly a hack. I wanted there to be no root element at all, and the filename (or, the last part of the url) would act as the root element. Kind of weird idea in hindsight, but kind of useful too. One downside is that there’d be no obvious way to specify attributes on the root element.
- nescioquid 4y agoFrom TFA: >> XML and Javascript are tree structures and not suitable for efficiently storing tabular data (plus other issues).
- javajosh 4y agoWhat does the acronym TFA mean here?
- tsimionescu 4y ago"The Fine Article" (though more traditionally, and/or depending on tone, "The Fucking Article").
- LeonB 4y agoI thought it was “the featured article” — in any case, it means in this context — “the linked url that this hacker news thread is discussing.”
- hermitcrab 4y ago"Javascript" was meant to be "JSON". (now fixed)
- barrkel 4y agoDoesn't have a great int64 number story, no native dates / date-times. If you want named tuples, then the names need to go everywhere, otherwise it's a serialization mechanism on top of JSON.
- tshaddox 4y agoI think the problem is that there is no clear standard or convention for how to do this. Indeed there are many ways to represent tabular data. Most large software projects probably have at least one bespoke file format that they use internally. The trouble is the lack of such a format that everyone agrees on.
- prepend 4y agoDoesn’t open in Excel. And since it doesn’t require one record per line it can be a hassle to read without having to parse it. It’s really nice to be able to do “head -n 5”
- saulpw 4y agojsonlines (jsonlines.org) is one record per line.
- bumper_crop 4y agoThis table has one column, one row, and thus one cell. What is its value? [{"col1":"val1", "col1":"val2"}]
- noitpmeder 4y agoIf you're really trying to replace csv with json, it would probably look like ["header1", "header2"] ["val1", "val2"] ... The entire file isn't valid JSON, but if you load each line independent of the next (jsonl), then you're fine.
- delusional 4y agoNot being able to do more is exactly the point. By restricting the space of the file format, we can free the mind to think about how to fit the data to the format. If you can do anything, it becomes hard to do the right thing. If you can only do the right thing, it becomes trivial to decide.
- Pxtl 4y agoThe repetition of the keys seems like the sore point here. I could see a specialized form of JSON using jagged arrays {"Header": ["Name", "Street Address", "City"] "Body": [ ["Alice", "123 Fake St", "Faketon"], ["Bob", "987 Any Pl", "Anytown"], ]} in that way the keys aren't repeated. It wouldn't be coherent useful JS objects when deserialized, but it would be trivial to convert js table object into a true array of Javascript objects.
- noitpmeder 4y agoNot great because you can't just append records without modifying the entire "body". Better to use JSONL!
- xxs 4y agoThat's inferior to even csv in any all its forms. It cannot be appended w/o removing the trailing square bracket. It requires column names per each row, you can't even know how many rows are there w/o parsing. It requires quotes (technical csv allows multiline rows but that's rarely used in practice) json is absolutely horrid for this type of hack-in jobs. Tabular data just not well structure data, easy to cut and paste.