diff --git a/CHANGELOG b/CHANGELOG index 3592061a..927f9981 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,13 @@ jc changelog -20221101 v1.22.2 +20221102 v1.22.2 - add `sshd_conf` parser - add `findmnt` parser +- enhance `xml` parser with optional `_` prefix for attributes instead of + `@` by using the `--raw` option. This can make it easier to filter the + JSON output in some tools. +- fix the `xml` parser to output a normal Dictionary instead of OrderdDict. + This cleans up YAML output. (No `!!omap` comments) - fix `csv` and `csv-s` parsers for UTF-8 encoded CSV files with leading BOM bytes - fix exit code to be non-zero on interrupt - allow parser module objects to be used as arguments to `jc.get_help()` and `jc.parser_info()` diff --git a/jc/parsers/xml.py b/jc/parsers/xml.py index cc434ef2..d82e7a72 100644 --- a/jc/parsers/xml.py +++ b/jc/parsers/xml.py @@ -108,7 +108,7 @@ def _process(proc_data, has_data=False): if has_data: # standard output with @ prefix for attributes - raw_output = xmltodict.parse(proc_data) + raw_output = xmltodict.parse(proc_data, dict_constructor=dict) return raw_output @@ -139,7 +139,7 @@ def parse(data, raw=False, quiet=False): if raw: if has_data: # modified output with _ prefix for attributes - raw_output = xmltodict.parse(data, attr_prefix='_') + raw_output = xmltodict.parse(data, dict_constructor=dict, attr_prefix='_') return raw_output