json4shell icon indicating copy to clipboard operation
json4shell copied to clipboard

Streaming json instead of loading whole object to memory.

Open noway opened this issue 11 years ago • 4 comments
trafficstars

Not always stdin give you all data instantly. So instead of waiting EOF, would be better to process json instantly. Some implementations of json readers with stream support: https://github.com/dominictarr/JSONStream https://pykler.github.io/yajl-py/ https://github.com/rtyler/py-yajl/

noway avatar Jun 02 '14 06:06 noway

Thanks, I'll look to it.

amarao avatar Jun 02 '14 10:06 amarao

I've checked JSONStream. May be I doing something wrong, but it does not process generator input until it done. Means it can't parse incoming stream. Failed attemt here: https://github.com/amarao/json4shell/tree/jsonstream/tools

amarao avatar Jun 16 '14 01:06 amarao

sys.stdout.flush() was the case. Also, appears that sys.stdin is not iterable in python2. I fixed it and it's working now. JSONSream is really nice choice, by the way. It doesn't require compilation, and it's written in pure python. Though it can be compiled as native python module (through cython), python version works fine. It can be even included directly in git repo! So there would be no need to do some extra deploy work while installing json4shell.

noway avatar Jun 17 '14 13:06 noway

Thanks!

I'll recheck it again.

On 06/17/2014 04:49 PM, Way, No wrote:

|sys.stdout.flush()| was the case. Also, appears that sys.stdin is not iterable in python2. I fixed it and it's working now. JSONSream is really nice choice, by the way. It doesn't require compilation, and it's written in pure python. Though it can be compiled as native python module (through cython), python version works fine. It can be even included directly in git repo! So there would be no need to do some extra deploy work while installing json4shell.

— Reply to this email directly or view it on GitHub https://github.com/amarao/json4shell/issues/3#issuecomment-46308747.

amarao avatar Jun 17 '14 13:06 amarao