json_serializer 0.0.1 json_serializer: ^0.0.1 copied to clipboard
Automatically convert JSON to dart objects in runtime without code generation.
json_serializer #
🚧 Experimental State 🚧
Automatically convert JSON to dart objects in runtime without code generation.
Setup #
To configure your project for the latest released version of
json_serializer
, see the [example].
Example #
Given a library example.dart
with an Person
class:
class Person {
final String firstName;
final String lastName;
final DateTime? dateOfBirth;
Person({
required this.firstName,
required this.lastName,
this.dateOfBirth,
});
}
Let json_serializer
know about your class
JsonSerializer.options = JsonSerializerOptions(userTypes: [
UserType<Person>(Person.new),
]);
And serialize a json to this class
JsonSerializer.deserialize<Person>(json);