nice_json 1.1.0 copy "nice_json: ^1.1.0" to clipboard
nice_json: ^1.1.0 copied to clipboard

A nice way to encode nice maps into nice-looking json.

example/example.dart

import 'package:nice_json/nice_json.dart';

void main(List<String> args) {
  Map<String, dynamic> data = {
    'a': [0, 1],
    'b': [
      [0, 1],
      [2, 3],
    ],
    'person': {'first_name': 'Alexander', 'last_name': 'Baker'},
    'cats': ['gau', 'saturn', 'yipyip', 'morgana'],
    'catscatscatscatscatscatscatscatscatscatscatscats': [
      'gau',
      'saturn',
      'yipyip',
      'morgana'
    ],
    'kittens': ['boy', 'violet', 'pumpkin'],
    'mixedList': [
      'boy',
      ['violet', 'pumpkin'],
      [1111111, 2222222, 3333333, 4444444, 5555555],
      {'name': 'saturn', 'age': 3, 'species': 'cat'},
    ],
    'locations': {
      'loc1': {'x': 0, 'y': -1.5},
      'loc2': {'x': -6.1, 'y': 2},
    },
    'book': 'a really really really really really long'
        ' string will obviously not get wrapped at all',
    'people': [
      {
        'name': 'Alice',
        'numbers': [1, 2, 3],
        'friends': ['Bob', 'Charlie'],
      },
      {
        'name': 'Bob',
        'numbers': [4, 5, 6],
        'friends': ['Alice', 'Charlie'],
      },
    ],
  };

  String json = niceJson(data,
      alwaysExpandKeys: ['kittens', 'locations.loc2', 'people.*.friends']);
  print(json);
}
2
likes
150
pub points
49%
popularity

Publisher

verified publisheralxbkr.xyz

A nice way to encode nice maps into nice-looking json.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on nice_json