diff --git a/prettyjson.dart b/prettyjson.dart new file mode 100644 index 0000000..b063714 --- /dev/null +++ b/prettyjson.dart @@ -0,0 +1,13 @@ +import 'dart:convert'; +import 'dart:io'; + +main(List args) async { + if (args.length == 0) { + print('File name is not assigned\nUsage: prettyjson.dart '); + return; + } + final jsonContent = await new File(args[0]).readAsString(); + final jsonDecoded = json.decode(jsonContent); + JsonEncoder encoder = new JsonEncoder.withIndent(' '); + print(encoder.convert(jsonDecoded)); +} diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..23fde30 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,3 @@ +name: + prettyjson.dart +