json_safe 0.0.2 copy "json_safe: ^0.0.2" to clipboard
json_safe: ^0.0.2 copied to clipboard

Safe JSON decoding & deserialization, JsonMap type, and pretty encoding

example/main.dart

// ignore_for_file: avoid_print

import 'package:json_safe/json_safe.dart';
import 'package:meta/meta.dart';

@immutable
class User {
  const User({required this.email, required this.userId});

  factory User.fromJson(JsonMap json) =>
      User(email: json['email']! as String, userId: json['userId']! as int);

  final String email;
  final int userId;
}

void main() {
  final user = deserializeJsonMap({
    'email': 'email@example.com',
    'userId': 1,
  }, fromJson: User.fromJson);

  print('Email: ${user.email}');
  print('Email: ${user.userId}');
}
0
likes
160
points
129
downloads

Documentation

API reference

Publisher

verified publisherechoellet.dev

Weekly Downloads

Safe JSON decoding & deserialization, JsonMap type, and pretty encoding

Repository (GitHub)
View/report issues

Topics

#json #utils

License

MIT (license)

More

Packages that depend on json_safe