safe_json 1.0.4 copy "safe_json: ^1.0.4" to clipboard
safe_json: ^1.0.4 copied to clipboard

A happy way to parse JSON in Dart which can avoid crush and show error detail in console. Primary purpose of this library is to find out backend error(incomplete data) at the first time.

example/main.dart

import 'models/user.dart';

void main() {
  Map<String, dynamic> json = {
    'age': '30.0',
    'articles': [
      'article1',
      'article2',
    ],
    'vehicles': [
      {'make': 'Toyota', 'model': 'Camry'},
      {'make': 'Honda', 'model': 'Accord'},
    ],
  };

  User user = User.fromJson(json);

  print(user.name); // John
  print(user.age); // 30
  print(user.school); // MIT
  print(user.articles); // [article1, article2]
  print(user.vehicles); // [Toyota Camry, Honda Accord]
}
1
likes
0
points
43
downloads

Publisher

unverified uploader

Weekly Downloads

A happy way to parse JSON in Dart which can avoid crush and show error detail in console. Primary purpose of this library is to find out backend error(incomplete data) at the first time.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on safe_json