Live data from Hacker News

Better Than JSON?

wiki.alopex.li

131–140 of 153 posts

Re: Better Than JSON?

#131
post #100

Earlier quoted context omitted.

How would you represent CSV in JSON?

An array of maps - each map is a row, each key a column.

Or an array of arrays with a TOC containing the keys to index mapping. Keeps the column order and it's more compact because it omits the keys in the data.

Re: Better Than JSON?

#132
post #60

if you are sending data to "yourself" and performance is important, defining your own binary protocol can be very effective. every time I go to grok protobuf, thrift, et al. I end up just rolling my own format because it's so much simpler and I can take all the tradeoffs that benefit what I'm doing instead of what anyone might possibly do with it. this doesn't apply in many situations (i.e. sending data to outside pa…

We only do that on embedded platforms, meaning MCUs. Anything that runs Linux is better off with CBOR or MessagePack or even ProtoBuf. Dunno about FreeRTOS et all. I've only seen libraries for JSON. ESP32 and Cortex M4 are powerful enough for serialization formats but at the expense of wasting cycles, so you're probably better off with a custom binary protocol most of the time. But if you want to sell your product to integrators use a well supported serialization format. Nobody is going to write decoders for your custom binary format today.

Re: Better Than JSON?

#133

I find it curious that serialization formats like JSON get hit on for not having a native date/time format. Just use a UNIX timestamp and be done with it.

https://tools.ietf.org/html/rfc7493 says to use an ISO 8601/RFC 3339 timestamp, uppercase, with timezone, with seconds. IOW, Javascript's toISOString() or equivalent.

You need to parse that. For graphs with thousands of data points just use Unix time plus a timezone or use the browser's timezone. ISO 8601 would leave your graphs churning for seconds.

Re: Better Than JSON?

#134

Just to be a broken record: JavaScript is better than JSON because it has loops, conditionals, comments, modules, functional programs, typing, etc etc

Which opens a lot of opportunities for potential attackers embedding malware into data and executing it remotely.

Re: Better Than JSON?

#135
Did a disservice to Thrift here. In my last job we had I think a hundred services communicating via Thrift. It's pretty fast, type definition is easy to read, has support for union types, and supports A TON of languages. We used the Java, Node, and PHP clients/servers...

Re: Better Than JSON?

#136
post #133

Earlier quoted context omitted.

https://tools.ietf.org/html/rfc7493 says to use an ISO 8601/RFC 3339 timestamp, uppercase, with timezone, with seconds. IOW, Javascript's toISOString() or equivalent.

You need to parse that. For graphs with thousands of data points just use Unix time plus a timezone or use the browser's timezone. ISO 8601 would leave your graphs churning for seconds.

If parse time is a significant concern, why are you using JSON?

Re: Better Than JSON?

#137
JSON is popular because of JS and web browsers. It's the native serialization format of the most popular platform, so naturally it is the most baby ducked. There are also pragmatic reasons such as browsers and various interpreters (Python) being faster at JSON than alternatives (thanks to years of hand optimization).

From an aesthetic point-of-view, XML is ideal. It reads like S-expressions or Lisp but with enough features to be a robust serialization format or even represent code. Validation alone puts it ahead of JSON. Too verbose? What kind of editor are you using that can't add the closing tag automatically or show you validation errors as you go. If type checking is good, then XML is good.

The main reason XML is hated now is that it's too difficult to learn.

People that care about performance will use protobufs/capnproto, which has all the safety of XML and more. People that want something to work out of the box everywhere without too much thought will use JSON. There is no room for caring about correctness for its own sake.

Re: Better Than JSON?

#138

> Apache is the tragic junkyard of open source projects This made me laugh more than it probably should have.

Apache, GNU, Boost

The kiss of death. It's a graveyard of things from a previous era, pure maintenance mode. I think library authors get tired of maintaining for free then hand it off to these life support organizations. The new way for open source software is a decentralized ecosystem where people fix software they actually use, so the cream rises to the top on its own and you don't need the sponsorship of these digital museums.

Re: Better Than JSON?

#139
post #107

On XML: > Not sure anyone really knows how XML happened. It’s > basically the W3C’s fault, I think? It’s okay for some > things but in the end I’m not sure it’s something anyone > actually wants to use, it’s just going to be one more of > those mistakes of the past. Look, I was doing web dev when XMLRPC was in. For simple API stuff, JSON ended up being worlds better. No fiddly XML preamble, no schemas, no envelopes,…

It's a shame the original article didn't mention XPath which is a great feature when you're in the XML ecosystem. (Obviously JSON has jq, but that's not a standard - so there's no library version - and has some weirdness compared to XPath).

JSON has the equivalent JSON Pointer described in RFC 6901 (https://tools.ietf.org/html/rfc6901).
Post reply on HN