Skip to content

Instantly share code, notes, and snippets.

@thorizer
Forked from kasperpeulen/README.md
Created April 1, 2022 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thorizer/8bf7fc97c2fd78fa3a8ed1d1d7392824 to your computer and use it in GitHub Desktop.
Save thorizer/8bf7fc97c2fd78fa3a8ed1d1d7392824 to your computer and use it in GitHub Desktop.
How to pretty-print JSON using Dart.
import 'dart:convert';
main() {
Map json = {
'name' : 'Kasper Peulen',
'best_language': 'dart',
'best_chat': 'https://dartlang.slack.com'
};
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
String prettyprint = encoder.convert(json);
print(prettyprint);
}
name: dart.convert_JsonEncoder.withIndent
description: |
How to pretty-print JSON using Dart.
How to display JSON in an easy-to-read (for human readers) format.
tags: 'json pretty-print'
homepage: https://gist.github.com/kasperpeulen/d61029fc0bc6cd104602
environment:
sdk: '>=1.0.0 <2.0.0'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment