Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is perfectly acceptable to design a library with a simplified, restricted interface that covers the majority of use cases, but not all. e.g. requests vs urllib2 For me, that's a win for common sense. I have never even considered streaming JSON. The lack of streaming support should be a clue that the OP needs to look at whether what he's attempting is even sensible or could be better served by a different transport protocol with built in streaming support.


JSON supports streaming. You not having considered it is not an argument.


Firstly:

http://www.ietf.org/rfc/rfc4627.txt

"An implementation may set limits on the size of texts that it accepts. " - How does that "support" streaming?

My argument is that most people don't need it most of the time (I can't prove this). It's also NOT a protocol designed for streaming. As regards API design, it's a matter of taste but my preference and that of many others who use python, as we can see with the popularity of requests, Flask, is that an API should be designed for simplicity for the common use cases rather than for absolute completeness. I'm not saying don't expose a low-level API full of BufferedReaders, JSONParserCursors, but don't force it on me to parse a tiny JSON document of known length.


The protocol can support streaming very well. How easy it is or if it's possible at all is an implementation issue. With the Go standard library's json implementation, for example, you can decode JSON streams very easily: http://golang.org/pkg/encoding/json/#example_Decoder




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: