dart_class_mapper 1.2.1
dart_class_mapper: ^1.2.1 copied to clipboard
Lightweight library for mapping classes in Dart. Ideal for converting between entities and DTOs objects with a simple and reusable API.
1.1.1 #
- Added more example in readme
1.2.0 #
Added #
-
Mapper: A
Mapperclass has been added with static methods to simplify the configuration and usage of mappings:-
static void configure(void Function(MapperConfiguration cfg) configure): Central entry point to register all mappings. -
static T map<T, R>(R value): Performs the mapping of an object from type R to type T using the registered mappings.
-
-
Enhanced JSON Mapping:
- Introduced
buildJsonMapinMapperConfigurationto define direct mappings between Dart objects and JSON (Map<String, dynamic>). - Added support for
.reverse()onbuildJsonMapfor bidirectional JSON to Object and Object to JSON conversions. - Implemented
JsonParsingHelpers(extension onJSONtype alias forMap<String, dynamic>) with utility methods for safe and convenient data extraction from JSON:getString(key, defaultValue?)getInt(key, defaultValue?)getDouble(key, defaultValue?)getBool(key, defaultValue?)getObject(key)getListOf<T>(key)mapToObject<Model>(key)(for nested JSON objects)mapToListOfObjects<Model>(key)(for lists of JSON objects)
- Added
toJson()extension method onObjectfor easy serialization of mapped objects to JSON. - Added
mapTo<T>({String key = ''})extension method onJSONfor deserialization, supporting extraction from a nested JSON key. - Added
toJsonList()extension onIterable<Object>for serializing lists of objects to lists of JSON. - Added
mapToObjectsList<T>()extension onList<JSON>for deserializing lists of JSON to lists of objects.
- Introduced
[1.1.1] #
- Adjust formatting
1.1.0 #
- Added reverse function on CreateMap
- Readme migrated to English
- Description migrated to English
1.0.2 #
- Description adjustment
1.0.1 #
- Description adjustment
1.0.0 #
- Initial version.