Logo

Programming-Idioms

Print the object x in human-friendly JSON format, with newlines and indentation.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import 'dart:convert';
var encoded = const JsonEncoder.withIndent('  ').convert(x);
print(encoded);
import "encoding/json"
import "fmt"
buffer, err := json.MarshalIndent(x, "", "  ")
if err != nil {
	log.Fatal(err)
}
fmt.Println(string(buffer))
import json
print(json.dumps(x, indent=4))
require 'json'
puts JSON.pretty_generate(x)