gfeldman commented on PR #26546:
URL: https://github.com/apache/airflow/pull/26546#issuecomment-1253113679
with `flask_app.json_encoder = AirflowJsonEncoder` setting
```
>>> from airflow.www import app
>>> from kubernetes.client import models as k8s
>>> p =
k8s.V1Pod(spec=k8s.V1PodSpec(containers=[k8s.V1Container(name="base")]))
>>> c = app.create_app()
>>> c.json.dumps(p)
'{"spec": {"containers": [{"name": "base"}]}}'
```
with `flask_app.json_provider_class = AirflowJsonEncoder`
```
>>> from airflow.www import app
>>> from kubernetes.client import models as k8s
>>> p =
k8s.V1Pod(spec=k8s.V1PodSpec(containers=[k8s.V1Container(name="base")]))
>>> c = app.create_app()
>>> c.json.dumps(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Users/guy.feldman/opt/anaconda3/lib/python3.9/site-packages/flask/json/provider.py",
line 230, in dumps
return json.dumps(obj, **kwargs)
File "/Users/guy.feldman/opt/anaconda3/lib/python3.9/json/__init__.py",
line 234, in dumps
return cls(
File "/Users/guy.feldman/opt/anaconda3/lib/python3.9/json/encoder.py",
line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/Users/guy.feldman/opt/anaconda3/lib/python3.9/json/encoder.py",
line 257, in iterencode
return _iterencode(o, 0)
File
"/Users/guy.feldman/opt/anaconda3/lib/python3.9/site-packages/flask/json/provider.py",
line 122, in _default
raise TypeError(f"Object of type {type(o).__name__} is not JSON
serializable")
TypeError: Object of type V1Pod is not JSON serializable
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]