Skip to content

parse datetime in response? #48

@ninsbl

Description

@ninsbl

Response of actinia requests may contain datetime values. Those are currently returned as string.
While it is easy to transform those to datetime objects, a question is whether e.g. the request_and_check function in utils.py should parse and datetime objects by default, using an object_hook for datetime here:

return json.loads(resp.text)

The object hook would look something like this:

from datetime import datetime


def datetime_hook(json_dict):
    for (key, value) in json_dict.items():
        try:
            json_dict[key] = datetime.fromisoformat(value)
        except:
            pass
    return json_dict

(...)

json.loads(response, object_hook=datetime_hook)

What do you think @mmacata

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions