encode decode for js