pretty_json 1.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

pretty_json #

A small wrapper to print JSON objects (Map<String,dynamic>) out neatly.

This is a small Dart wrapper for printing JSON (represented as Map<String,dynamic> in Dart) in a more readable format. Please consider following the author of this project to show some ❤️, Ferdinand Steenkamp and starring the project ⭐ if you use it.

Install #

Install with pub.dev, add this to your pubspec.yaml:

dependencies:
    pretty_json:

Then run pub get or flutter pub get

Usage #

Import the package:

import 'package:pretty_json/pretty_json.dart';

Printing an object out:

void main() {
    
    var json = Map<String,dynamic>{
      'a': 'value a',
      'b': 'value b',
      'c': {  
          'd': 'value d',
          'e': [
            1,
            2,
            3
          ]
      },
    }

    //prettyJson returns a string
    print(prettyJson(json, indent: 2));
    
    //printPrettyJson does the print for us
    printPrettyJson(json, indent: 2);
}

Params:

@required Map<String,dynamic>
@optional indent: int

About #

Pull requests and issues always welcome.

Author #

Ferdinand Steenkamp

License #

Copyright © 2020, Ferdinand Steenkamp. Released under the BSD License.

1.0.9 #

  • Fixed indentation bug

1.0.8 #

  • Docs fix

1.0.7 #

  • Added printPrettyJson function

1.0.6 #

  • Small documentation fix

1.0.5 #

  • Small documentation fix

1.0.4 #

  • Small documentation fix

1.0.3 #

  • Small documentation fix

1.0.2 #

  • Small documentation fix

1.0.1 #

  • Small documentation fix

1.0.0 #

  • Initial release

example/pretty_json_example.dart

import 'package:pretty_json/pretty_json.dart';

void main() {
  var json = <String, dynamic>{
    'a': 'value 1',
    'b': 'value 2',
    'c': {
      'd': 'value 3',
      'e': [1, 2, 3]
    }
  };

  print(prettyJson(json, indent: 2));
  printPrettyJson(json);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pretty_json: ^1.0.9

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pretty_json/pretty_json.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
71
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Jun 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0