I have done some digging and there seems to be a problem with *to_nice_json*
.

if I use

-{{ hostvars | *to_nice_json* }} 

it breaks

if I use

-{{ hostvars | *to_json* }}

It works correctly


def to_json(a, *args, **kw):
    ''' Convert the value to JSON '''
    return json.dumps(a, *args, **kw)
def to_nice_json(a, *args, **kw):
    '''Make verbose, human readable JSON'''
    return json.dumps(a, indent=4, sort_keys=True, *args, **kw)

It does look like it uses a different encoder under the hood if indent & 
sorting is enabled

https://sourcegraph.com/hg.python.org/cpython@default/.PipPackage/Python/.def/json/dumps/cls?_codeview=1

    # cached encoder
    if (not skipkeys and ensure_ascii and
        check_circular and allow_nan and
        cls is None and indent is None and separators is None and
        default is None and not sort_keys and not kw):
        return _default_encoder.encode(obj)
    if cls is None:
        cls = JSONEncoder
    return cls(
        skipkeys=skipkeys, ensure_ascii=ensure_ascii,
        check_circular=check_circular, allow_nan=allow_nan, indent=indent,
        separators=separators, default=default, sort_keys=sort_keys,
        **kw).encode(obj)





-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/21503233-bb72-4219-b13a-dfc2703f11bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to