do proper json encoding of result