add option to use json or binary protocol