You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/29 15:02:17 UTC

[GitHub] [airflow] jonasrla edited a comment on issue #13934: EMR URI Parse Fails to resolve nested dict objects

jonasrla edited a comment on issue #13934:
URL: https://github.com/apache/airflow/issues/13934#issuecomment-769856714


   I already thought a little about it. What do you think of doing this:
   ```python
               self.extra = self.parse_extra(uri_parts.query)
   
       def parse_extra(query):
           extra = dict()
           for key, value in parse_qsl(query, keep_blank_values=True):
               try:
                   extra[key] = json.loads(value.replace("'", '"'))
               except json.JSONDecodeError:
                   extra[key] = value
           return json.dumps(extra)
   ```
   
   That is, instead of using `dict()` as parser, use `json.loads()`. The only issue is that I'm using `try catch` to decide whether the value is a valid dictionary or just a string. I, myself, am not a huge fan of using `try catch` where it should be `if else`.
   
   What do you think?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org