Pretty print JSON data.

    Parameters
    ----------
    data
        JSON data.
    indent : `int`, optional
        Indent level in characters (default: 0).
    end : `str`, optional
        String to print after the data (default: '\\\\n').
171114
def pprint(data, indent=0, end='\n'):
    
    if isinstance(data, dict):
        print('{')
        new_indent = indent + 4
        space = ' ' * new_indent
        keys = list(sorted(data.keys()))
        for i, k in enumerate(keys):
            print(space, json.dumps(k), ': ', sep='', end='')
            pprint(data[k], new_indent,
                   end=',\n' if i < len(keys) - 1 else '\n')
        print(' ' * indent, '}', sep='', end=end)
    elif isinstance(data, list):
        if any(isinstance(x, (dict, list)) for x in data):
            print('[')
            new_indent = indent + 4
            space = ' ' * new_indent
            for i, x in enumerate(data):
                print(space, end='')
                pprint(x, new_indent,
                       end=',\n' if i < len(data) - 1 else '\n')
            print(' ' * indent, ']', sep='', end=end)
        else:
            print(json.dumps(data), end=end)
    else:
        print(json.dumps(data), end=end)
1195629
protected static function prettyPrint($json)
    {
        $result = '';
        $pos = 0;
        $indentation = '    ';
        $newline = "\n";
        $previousChar = '';
        $outOfQuotes = true;

        // Unescape slashes.
        if (strpos($json, '/')) {
            $json = preg_replace('#\134{1}/#', '/', $json);
        }

        $stringLength = strlen($json);

        for ($i = 0; $i <= $stringLength; $i++) {

            // Grab the next character in the string.
            $char = substr($json, $i, 1);

            if (':' == $previousChar && $outOfQuotes) {
                $result .= ' ';
            }

            // Are we inside a quoted string?
            if ('"' == $char && $previousChar != '\\') {
                $outOfQuotes = !$outOfQuotes;

                // If this character is the end of an element,
                // output a new line and indent the next line.
            } elseif (('}' == $char || ']' == $char) && $outOfQuotes) {
                $result .= $newline;
                $pos --;
                for ($j = 0; $j < $pos; $j++) {
                    $result .= $indentation;
                }
            }

            // Add the character to the result string.
            $result .= $char;

            // If the last character was the beginning of an element,
            // output a new line and indent the next line.
            if ((',' == $char || '{' == $char || '[' == $char) && $outOfQuotes) {
                $result .= $newline;
                if ('{' == $char || '[' == $char) {
                    $pos ++;
                }

                for ($j = 0; $j < $pos; $j++) {
                    $result .= $indentation;
                }
            }

            $previousChar = $char;
        }

        return $result;
    }
1013190
def output(data, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''

    params = {}
    if 'output_indent' not in __opts__:
        # default indentation
        params.update(default_flow_style=False)
    elif __opts__['output_indent'] >= 0:
        # custom indent
        params.update(default_flow_style=False,
                      indent=__opts__['output_indent'])
    else:  # no indentation
        params.update(default_flow_style=True,
                      indent=0)
    try:
        return salt.utils.yaml.safe_dump(data, **params)
    except Exception as exc:
        import pprint
        log.exception(
            'Exception %s encountered when trying to serialize %s',
            exc, pprint.pformat(data)
        )
284938
def pretty_format(obj, indent=None):
        
        if indent is None:
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                return '{}({})'.format(obj.get('_', 'dict'), ', '.join(
                    '{}={}'.format(k, TLObject.pretty_format(v))
                    for k, v in obj.items() if k != '_'
                ))
            elif isinstance(obj, str) or isinstance(obj, bytes):
                return repr(obj)
            elif hasattr(obj, '__iter__'):
                return '[{}]'.format(
                    ', '.join(TLObject.pretty_format(x) for x in obj)
                )
            else:
                return repr(obj)
        else:
            result = []
            if isinstance(obj, TLObject):
                obj = obj.to_dict()

            if isinstance(obj, dict):
                result.append(obj.get('_', 'dict'))
                result.append('(')
                if obj:
                    result.append('\n')
                    indent += 1
                    for k, v in obj.items():
                        if k == '_':
                            continue
                        result.append('\t' * indent)
                        result.append(k)
                        result.append('=')
                        result.append(TLObject.pretty_format(v, indent))
                        result.append(',\n')
                    result.pop()  # last ',\n'
                    indent -= 1
                    result.append('\n')
                    result.append('\t' * indent)
                result.append(')')

            elif isinstance(obj, str) or isinstance(obj, bytes):
                result.append(repr(obj))

            elif hasattr(obj, '__iter__'):
                result.append('[\n')
                indent += 1
                for x in obj:
                    result.append('\t' * indent)
                    result.append(TLObject.pretty_format(x, indent))
                    result.append(',\n')
                indent -= 1
                result.append('\t' * indent)
                result.append(']')

            else:
                result.append(repr(obj))

            return ''.join(result)
971947
def prettyprint(d):
        
        print(json.dumps(d, sort_keys=True, 
                         indent=4, separators=("," , ": ")))
413317
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        condition = pretty_str(self.condition)
        pretty = '{}switch ({}):\n'.format(spaces, condition)
        pretty += self.body.pretty_str(indent=indent + 2)
        return pretty
678342
function pprintJSON(formJson, opts, indentLevel, priorNodeStr) {
  opts = opts || {};
  opts.spaces = opts.spaces || 2;
  opts.lbracket = opts.lbracket || "[";
  opts.rbracket = opts.rbracket || "]";
  opts.separator = opts.separator || ", ";
  indentLevel = indentLevel || 0;
  var nl = opts.oneLine ? " " : "\n";
  var str = ""

  function indentToSpaces(indentLevel) {
    return(!opts.omitTop ? indentLevel * opts.spaces : (indentLevel - 1) * opts.spaces);
  }

  if(Array.isArray(formJson)) {
    var numSpaces = indentToSpaces(indentLevel);
    if(!(opts.omitTop && indentLevel === 0)) {
      // I added these last two checks below specifically for formatting html tags
      // (the length check might adversely effect formatting normal code not sure yet )
      if((priorNodeStr !== '"function"' && priorNodeStr !== 'function') &&
          formJson.length > 0 && formJson[0] !== "attr") {
        str += (priorNodeStr ? nl : "") // omit the unecessary *first* "\n"
        str += (priorNodeStr && numSpaces > 0 ? " ".repeat(numSpaces) : "")
      }
      str += opts.lbracket
    }

    if(formJson[0] === "object" || formJson[0] === "attr") {
      if(opts.attrsAsJson || opts.objectsAsJson) {
        // pretty print the key/value pairs of an object/attr as a js object:
        str += "{";
        for(var i=1; i<formJson.length;i+=2) {
          if(i === 1) { str += nl; }
          var propNameStr = pprintJSON(formJson[i], opts);
          propNameStr = ((propNameStr.indexOf("-") !== -1) ? '"' + propNameStr + '"' : propNameStr);
          str += (numSpaces+1 > 0 ? " ".repeat(indentToSpaces(indentLevel+1)) : "") +
                  propNameStr + ": " +
                  pprintJSON(formJson[i+1], opts, indentLevel + 2, formJson[i]) + (i+2 < formJson.length ? opts.separator : "") + nl;
        }
        str += "}";
      }
      else {
        // pretty print the key/value pairs of an object/attr as an s-expr list
        str += pprintJSON(formJson[0], opts) + opts.separator + nl;
        for(var i=1; i<formJson.length;i+=2) {
          str += (numSpaces+1 > 0 ? " ".repeat(indentToSpaces(indentLevel+1)) : "") +
                 pprintJSON(formJson[i], opts) + opts.separator +
                 pprintJSON(formJson[i+1], opts, indentLevel + 2, formJson[i]) + (i+2 < formJson.length ? opts.separator : "") + nl;
        }
      }
    }
    else {
      // pretty print the body of a normal list
      var priorNodeStr;
      formJson.forEach(function(node, i) {
        priorNodeStr = pprintJSON(node, opts, indentLevel + 1, priorNodeStr)
        str += priorNodeStr
        if(i < formJson.length - 1) {
          str += opts.separator
        }
      })
    }
    if(!(opts.omitTop && indentLevel === 0)) {
      str += opts.rbracket
    }
  }
  else if(formJson == null) {
    str += "null";
  }
  else if(typeof formJson === 'string' && !opts.bareSymbols) {
    // I had backslashed single quotes below -
    // but jsonlint rejected so I don't...
    str += ('"' + formJson.replace(/[\\"]/g, '\\$&') + '"')
  }
  else if(formJson.toString) {
    str += formJson.toString();
  }
  else {
    throw new Error('Unknown form type in pprintJSON: ' + formJson + ' (' + typeof formJson + ')');
  }
  return str
}
1152988
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        pretty = '{}({})' if self.parenthesis else '{}{}'
        name = ('{}.{}'.format(self.field_of.pretty_str(), self.name)
                if self.field_of else self.name)
        return pretty.format(spaces, name)
1276734
function stringifyIndented(value, chr, n) {
  return indent(JSON.stringify(value, null, n), chr, n).slice(chr.length * n)
}
1346439
def encode_json_body(data):
    
    # support for StringIO / file - like objects
    if hasattr(data, "read"):
        return data

    response.content_type = "application/json; charset=utf-8"

    return json.dumps(
        data,
        indent=4,
        separators=(',', ': ')
    )
402413
def pretty_str(self, indent=0):
        
        indent = ' ' * indent
        if self.value is not None:
            return '{}{} {}'.format(indent, self.name, pretty_str(self.value))
        return indent + self.name
1274066
def print_data(data):
    
    print(", ".join(["{}=>{}".format(key, value) for key, value in data]))
608201
def write_data(data):
    

    sorted_dict = sort_recursive(data)

    with open(_datafile, 'w') as file:
        _json.dump(sorted_dict, file, indent=2)
79958
def __dumps(*args, **kwargs):
    
    indent = None
    if (current_app.config.get('JSONIFY_PRETTYPRINT_REGULAR', False) and
            not request.is_xhr):
        indent = 2
    return json.dumps(args[0] if len(args) is 1 else dict(*args, **kwargs),
                      indent=indent)
240075
def pretty_dumps(data):
    
    try:
        return json.dumps(data, sort_keys=True, indent=4, ensure_ascii=False)
    except:
        return json.dumps(data, sort_keys=True, indent=4, ensure_ascii=True)
975937
def pretty(self, indent=0, indent_str='  '):
        
        return '{0}{1}({2!r}): {3!r}'.format(
            indent_str * indent,
            self.__class__.__name__,
            self.name,
            self.value
        )
1312870
function prettyPrint(json, tabs){
		var result = "";
		
		for (var property in json) {
		    var value = json[property];
		    
		    if(value === undefined) {
				continue;
		    }
		    
		    if(_isJSON(value)){ result += prettyPrint(value, tabs + 1); }
		    else { result += _appendTabs(property + " : " + value + "\n", tabs); }
		}
		
		return result;
	}