json_serializable 5.0.2 copy "json_serializable: ^5.0.2" to clipboard
json_serializable: ^5.0.2 copied to clipboard

SDKDart
outdated

Automatically generate code for converting to and from JSON by annotating Dart classes.

example/example.dart

// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:json_annotation/json_annotation.dart';

part 'example.g.dart';

@JsonSerializable()
class Person {
  final String firstName;
  final String lastName;
  final DateTime? dateOfBirth;
  Person({required this.firstName, required this.lastName, this.dateOfBirth});
  factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
  Map<String, dynamic> toJson() => _$PersonToJson(this);
}
3.74k
likes
130
points
2.19M
downloads

Publisher

verified publishergoogle.dev

Weekly Downloads

Automatically generate code for converting to and from JSON by annotating Dart classes.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

analyzer, build, build_config, collection, json_annotation, meta, path, source_gen, source_helper

More

Packages that depend on json_serializable