Move `to_json` call upstream.