json_serializable2 3.5.2 copy "json_serializable2: ^3.5.2" to clipboard
json_serializable2: ^3.5.2 copied to clipboard

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(nullable: false)
class Person {
  final String firstName;
  final String lastName;
  final List<String> extras;
  final DateTime dateOfBirth;
  final int year;
  final double age;

  Person(this.year, this.age,
      {this.firstName, this.lastName, this.extras, this.dateOfBirth});

  factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);

  Map<String, dynamic> toJson() => _$PersonToJson(this);
}
0
likes
30
points
55
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

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

More

Packages that depend on json_serializable2