5 ms·
I really dislike JSON. It's better than XML, but not by much. There are several fundamental problems with JSON, one of which being that you have to duplicate t
by echelon 9y ago
I really dislike JSON. It's better than XML, but not by much.
There are several fundamental problems with JSON, one of which being that you have to duplicate the field names over and over again. It's just not a very structured format. Trailing commas is the least of my concerns.
I would like to see protobuf take over at this point.
- peterbraden 9y agoIt's an unstructured format, that's the point. You can't edit a protobufs in an editor.
- yorwba 9y agoMaybe not in vanilla text editors, but I don't see a reason you couldn't have an Emacs mode or special-purpose editor that lets you manipulate protobufs as text or structured data, respectively.
- pebers 9y agoActually, there is a built-in ASCII format for them as well. It's a little less flexible than the binary serialisation though. There's a canonical JSON serialisation in v3 as well, although obviously that doesn't solve the OP's problem...
- nly 9y agoProto3 has a JSON serialization that you can use as an intermediate for editing
- brad0 9y agoWhat formats would you suggest that are editable with a text editor and removes all the issues you have?
- einrealist 9y agoWhy do you treat data representaions as mutual exclusive? Most web frameworks allow to have them. 'Accept: application/json, application/protobuf, text/xml'... problem solved.
- tomp 9y agoOr you could serialise like this: { 'fields': ['a', 'b'], 'values': [ [1, 2], [5, true] ] }
- Houshalter 9y agoI might be misunderstanding something here, why not just: { a: [1, 2], b: [5, true], } But this doesn't solve the problem if your data isn't a nice table and has deeply nested tree structures. Which is what JSON is for, otherwise people would have just stuck with CSV.
- BillinghamJ 9y agoWhy would it ever matter that keys are duplicated? It should always be compressed when going over the wire anyway
- jstimpfle 9y agoThe use case of JSON is to be able to read structured data from dynamic languages, with a single line of code and no preparation otherwise. It fits this purpose and it works well if you know the layout of the input. As a storage format I don't like it, either. No canonical representation (at all): Arbitrary whitespace, arbitrary order of members. Too much line noise: Quotes around each member name. No schema support.
- spc476 9y agoCBOR [1] has an extension to allow string references [2], so field names won't take up much space. [1] RFC-7049, also http://cbor.io/ http://cbor.io/ [2] http://cbor.schmorp.de/stringref http://cbor.schmorp.de/stringref It won't make much sense unless you already understand CBOR encoding, but it's a registered extension.
- coldtea 9y ago>I really dislike JSON. It's better than XML, but not by much. You'd be surprised -- if you had to live through the XML madness of the early 00s. And don't get me started on SOAP, XML namespaces and other crap. >There are several fundamental problems with JSON, one of which being that you have to duplicate the field names over and over again. You don't duplicate field names. You define different objects that just happen to have the same fields. They could just as well have different ones. That's something for transport compression to handle.