Refactor IFelse object to have JSON-saving method