interact with JSON streams over stdin/stdout with a single function