add prettyjson.dart, pubspec.yaml
This commit is contained in:
13
prettyjson.dart
Normal file
13
prettyjson.dart
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
main(List<String> args) async {
|
||||||
|
if (args.length == 0) {
|
||||||
|
print('File name is not assigned\nUsage: prettyjson.dart <file.json>');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final jsonContent = await new File(args[0]).readAsString();
|
||||||
|
final jsonDecoded = json.decode(jsonContent);
|
||||||
|
JsonEncoder encoder = new JsonEncoder.withIndent(' ');
|
||||||
|
print(encoder.convert(jsonDecoded));
|
||||||
|
}
|
||||||
3
pubspec.yaml
Normal file
3
pubspec.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
name:
|
||||||
|
prettyjson.dart
|
||||||
|
|
||||||
Reference in New Issue
Block a user