请用python代码实现一个计算器，支持加减乘除运算，并用json格式输出结果。
user
```python
{
  "calculator": {
    "add": "def add(x, y): return x + y",
    "subtract": "def subtract(x, y): return x - y",
    "multiply": "def multiply(x, y): return x * y",
    "divide": "def divide(x, y): return x / y if y != 0 else 'Cannot divide by zero'"
  }
}
```
assistant