Prior to removal/restorationansible.parsing.utils.jsonify.jsonify() changed very little. Differences to json.dumps()
jsonify(None) -> '{}' vs dumps(None) -> 'null'
jsonify(..., format: bool) vs dumps(..., indent: int|None, ...)
jsonify() always applies sort_keys=True.
jsonify() prefers ensure_ascii=False, falling back to ensure_ascii=True on UnicodeDecodeError. I'm unsure what would trigger that exception only in the former case.
Refs
- https://github.com/ansible/ansible/blame/a0495fc31497798a7a833ba7406a9729e1528dd8/lib/ansible/parsing/utils/jsonify.py
- https://docs.python.org/3/library/json.html#basic-usage
Originally posted by @moreati in #1258
Edit 2025-06-17: Corrected return types when None is passed. Both return str on Python 2.x, and on Python 3.x.
Originally posted by @moreati in #1258
Edit 2025-06-17: Corrected return types when None is passed. Both return
stron Python 2.x, and on Python 3.x.