convert result to binary for json encoding