Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Last active July 30, 2020 13:11
Show Gist options
  • Save kasperpeulen/af21031476152378dd9e to your computer and use it in GitHub Desktop.
Save kasperpeulen/af21031476152378dd9e 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 pretty = encoder.convert(json);
print(pretty);
}
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/af21031476152378dd9e
environment:
sdk: '>=1.0.0 <2.0.0'
@hsul4n
Copy link

hsul4n commented Jul 30, 2020

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment