We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the default yaml loader will parse ISOFormat strings and create datetime objects which doesn't jsonify well.
Example:
$ yq --version usage: yq [-h] [--yaml-output] [--width WIDTH] jq_filter [file [file ...]] yq: error: too few arguments $ pip freeze | grep yq yq==2.1.2 $ yq . sec.yaml yq: Error while running jq: TypeError: datetime.datetime(2016, 12, 20, 22, 7, 36) is not JSON serializable. parse error: Unfinished JSON term $ cat sec.yaml data: thing: 1 thing2: "stuff" datething: 2016-12-20T22:07:36Z datethingstr: "2016-12-20T22:07:36Z"
this needs to override the default encoder class.
# isoformat class DateTimeEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, datetime): return o.isoformat() return json.json.JSONEncoder.default(self, o) # usage json.dumps(..., cls=DateTimeEncoder)
The text was updated successfully, but these errors were encountered:
Thanks! I can work on this tonight and cut a release, but if you wish to open a PR sooner, i can merge today.
Sorry, something went wrong.
fbd8a1a
Released in v2.2.0
looks fixed, thanks 👍
No branches or pull requests
the default yaml loader will parse ISOFormat strings and create datetime objects which doesn't jsonify well.
Example:
this needs to override the default encoder class.
The text was updated successfully, but these errors were encountered: