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 TOML loader suffers from the same issue the YAML loader suffered in #5, where it fails to encode datetime values when passing them to jq:
jq
$ tomlq --version tomlq 3.1.0 $ pip freeze | grep yq yq==3.1.0 $ tomlq . stuff.toml tomlq: Error running jq: TypeError: Object of type datetime is not JSON serializable. parse error: Unfinished JSON term at EOF at line 1, column 22 $ cat stuff.toml [table] expires = 9999-12-31T23:59:59.999999
If the output is encoded to something else (e.g. YAML), things work fine:
$ tomlq -y . stuff.toml table: expires: '9999-12-31T23:59:59.999999'
I think this is caused by the omission of the JSONDateTimeEncoder in the non-converting case, which would imply this also affects xq:
JSONDateTimeEncoder
xq
--- a/yq/__init__.py 2023-02-15 13:16:35.800556554 +0100 +++ b/yq/__init__.py 2023-02-20 13:03:23.020764028 +0100 @@ -252,12 +252,12 @@ import xmltodict for input_stream in input_streams: json.dump(xmltodict.parse(input_stream.read(), disable_entities=True, - force_list=xml_force_list), jq.stdin) + force_list=xml_force_list), jq.stdin, cls=JSONDateTimeEncoder) jq.stdin.write("\n") elif input_format == "toml": import toml for input_stream in input_streams: - json.dump(toml.load(input_stream), jq.stdin) + json.dump(toml.load(input_stream), jq.stdin, cls=JSONDateTimeEncoder) jq.stdin.write("\n") else: raise Exception("Unknown input format")
The text was updated successfully, but these errors were encountered:
479e416
Thanks, fixed. XML does not have native datetime literals that I'm aware of, so should not be affected.
Sorry, something went wrong.
No branches or pull requests
The TOML loader suffers from the same issue the YAML loader suffered in #5, where it fails to encode datetime values when passing them to
jq
:If the output is encoded to something else (e.g. YAML), things work fine:
I think this is caused by the omission of the
JSONDateTimeEncoder
in the non-converting case, which would imply this also affectsxq
:The text was updated successfully, but these errors were encountered: