Kyle Brooks created AIRFLOW-3331:
------------------------------------
Summary: Add JsonHttpOperator to push JSON HTTP responses to xcoms
Key: AIRFLOW-3331
URL: https://issues.apache.org/jira/browse/AIRFLOW-3331
Project: Apache Airflow
Issue Type: New Feature
Components: operators
Reporter: Kyle Brooks
For HTTP REST APIs that return JSON, it would be nice to be able to push the
decoded dictionary to xcoms instead of the undecoded JSON string.
I'm thinking something like this would work:
{code:java}
from airflow.operators.http_operator import SimpleHttpOperator
import json
class JsonHttpOperator(SimpleHttpOperator):
def execute(self, context):
response = super(JsonHttpOperator, self).execute(self, context)
if response is not None:
return json.loads(response){code}
Then, in a template you could use the dictionary instead of having to decode
the JSON first:
{\{ task_instance.xcom_pull(task_ids='dict_xcom')['key'] }}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)