def output(data, **kwargs):  # pylint: disable=unused-argument
    '''
    Print the output data in JSON
    '''
    try:
        if 'output_indent' not in __opts__:
            return salt.utils.json.dumps(data, default=repr, indent=4)

        indent = __opts__.get('output_indent')
        sort_keys = False

        if indent is None:
            indent = None

        elif indent == 'pretty':
            indent = 4
            sort_keys = True

        elif isinstance(indent, int):
            if indent >= 0:
                indent = indent
            else:
                indent = None

        return salt.utils.json.dumps(data, default=repr, indent=indent, sort_keys=sort_keys)

    except UnicodeDecodeError as exc:
        log.error('Unable to serialize output to json')
        return salt.utils.json.dumps(
            {'error': 'Unable to serialize output to json',
             'message': six.text_type(exc)}
        )

    except TypeError:
        log.debug('An error occurred while outputting JSON', exc_info=True)
    # Return valid JSON for unserializable objects
    return salt.utils.json.dumps({})
def output ( data , ** kwargs ) : try : if 'output_indent' not in __opts__ : return salt . utils . json . dumps ( data , default = repr , indent = 4 ) indent = __opts__ . get ( 'output_indent' ) sort_keys = False if indent is None : indent = None elif indent == 'pretty' : indent = 4 sort_keys = True elif isinstance ( indent , int ) : if indent >= 0 : indent = indent else : indent = None return salt . utils . json . dumps ( data , default = repr , indent = indent , sort_keys = sort_keys ) except UnicodeDecodeError as exc : log . error ( 'Unable to serialize output to json' ) return salt . utils . json . dumps ( { 'error' : 'Unable to serialize output to json' , 'message' : six . text_type ( exc ) } ) except TypeError : log . debug ( 'An error occurred while outputting JSON' , exc_info = True ) return salt . utils . json . dumps ( { } )
Print the output data in JSON