Avoid some string copying when converting to protobuf / JSON