All Projects → marazt → Object Mapper

marazt / Object Mapper

Licence: mit
ObjectMapper is a class for automatic object mapping in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Object Mapper

Batmap
🦇 Convention-based, fast object mapper.
Stars: ✭ 210 (+191.67%)
Mutual labels:  mapper, mapping
Jmapper Core
Elegance, high performance and robustness all in one java bean mapper
Stars: ✭ 159 (+120.83%)
Mutual labels:  mapper, mapping
Mapster
A fast, fun and stimulating object to object Mapper
Stars: ✭ 1,375 (+1809.72%)
Mutual labels:  mapper, mapping
Agilemapper
A zero-configuration, highly-configurable, unopinionated object mapper with viewable execution plans. Flattens, unflattens, deep clones, merges, updates and projects queries. Targets .NET 3.5+ and .NET Standard 1.0+
Stars: ✭ 345 (+379.17%)
Mutual labels:  mapper, mapping
orika-spring-boot-starter
Spring Boot Starter for Orika.
Stars: ✭ 116 (+61.11%)
Mutual labels:  mapping, mapper
JSONUtilities
Easily load JSON objects and decode them into structs or classes
Stars: ✭ 57 (-20.83%)
Mutual labels:  mapping, mapper
Bull
BULL - Bean Utils Light Library
Stars: ✭ 150 (+108.33%)
Mutual labels:  mapper, mapping
awesome-maps-ukraine
A curated list of maps of Ukraine, ukrainian mappers and tools that they use or develop for creating and publish maps
Stars: ✭ 35 (-51.39%)
Mutual labels:  mapping, mapper
Poiji
🍬 A tiny library converting excel rows to a list of Java objects based on Apache POI
Stars: ✭ 255 (+254.17%)
Mutual labels:  mapper, mapping
Mappinggenerator
🔄 "AutoMapper" like, Roslyn based, code fix provider that allows to generate mapping code in design time.
Stars: ✭ 831 (+1054.17%)
Mutual labels:  mapper, mapping
Capsicain
Powerful low-level keyboard remapping tool for Windows
Stars: ✭ 51 (-29.17%)
Mutual labels:  mapping
Shapefiles
Useful shapefiles
Stars: ✭ 52 (-27.78%)
Mutual labels:  mapping
Datawrapper
An open source data visualization platform helping everyone to create simple, correct and embeddable charts in minutes.
Stars: ✭ 1,133 (+1473.61%)
Mutual labels:  mapping
Grid map
Universal grid map library for mobile robotic mapping
Stars: ✭ 1,135 (+1476.39%)
Mutual labels:  mapping
Lenz
Console based MAP 🗺 : with lots of features 🤩
Stars: ✭ 51 (-29.17%)
Mutual labels:  mapping
Find Maraudersmap
Internal positioning for everyone, in the style of Harry Potter
Stars: ✭ 62 (-13.89%)
Mutual labels:  mapping
Papyrusjs
papyrus.js renders maps of Minecraft: Bedrock Edition worlds using node.js, LevelDB and leaflet.
Stars: ✭ 50 (-30.56%)
Mutual labels:  mapping
Rom Repository
THIS PROJECT WAS MOVED TO rom-rb/rom
Stars: ✭ 48 (-33.33%)
Mutual labels:  mapping
Geoserver
geoserver is a Go library for manipulating a GeoServer instance via the GeoServer REST API.
Stars: ✭ 48 (-33.33%)
Mutual labels:  mapping
Mirdeep2
Discovering known and novel miRNAs from small RNA sequencing data
Stars: ✭ 70 (-2.78%)
Mutual labels:  mapping

Object Mapper

Version 1.1.0

Author marazt

Copyright marazt

License The MIT License (MIT)

Last updated 13 July 2019

Package Download https://pypi.python.org/pypi/object-mapper

Build Status Build Status


Versions

1.1.0 - 2019/07/13

1.0.7 - 2019/06/19

  • Fix type name inside mapper dict to avoid collision, thanks @renanvieira

1.0.6 - 2018/10/28

  • Added ability to specify excluded fields, thanks @uralov

1.0.5 - 2018/02/21

  • Support for dynamic properties @nijm

1.0.4 - 2017/11/03

  • Migration to new Pypi.org deployment

1.0.3 - 2015/05/15

1.0.2 - 2015/05/06

1.0.1 - 2015/02/19

  • Fix of the package information

1.0.0 - 2015/02/19

  • Initial version

About

ObjectMapper is a class for automatic object mapping inspired by .NET AutoMapper. It helps you to create objects between project layers (data layer, service layer, view) in a simple, transparent way.

Example

  1. Mapping of the properties without mapping definition

In this case are mapped only these properties of the target class which are in target and source classes. Other properties are not mapped. Suppose we have class A with attributes name and last_name and class B with attribute name. Initialization of the ObjectMapper will be:

mapper = ObjectMapper()
mapper.create_map(A, B)
instance_b = mapper.map(A(), B)

In this case, value of A.name will be copied into B.name.

  1. Mapping with defined mapping functions

Suppose we have class A with attributes first_name and last_name , class B with attribute full_name and class C with attribute reverse_name. And want to map it in a way B.full_name = A.first_name + A.last_name and C.reverse_name = A.last_name + A.first_name Initialization of the ObjectMapper will be:

mapper = ObjectMapper()
mapper.create_map(A, B, {'name': lambda a : a.first_name + " " + a.last_name})
mapper.create_map(A, C, {'name': lambda a : a.last_name + " " + a.first_name})

instance_b = mapper.map(A(), B)
instance_c = mapper.map(A(), C)

In this case, to the B.name will be mapped A.first_name + " " + A.last_name In this case, to the C.name will be mapped A.last_name + " " + A.first_name

  1. Mapping suppression

For some purposes, it can be needed to suppress some mapping. Suppose we have class A with attributes name and last_name and class B with attributes name and last_name. And we want to map only the A.name into B.name, but not A.last_name to B.last_name Initialization of the ObjectMapper will be:

mapper = ObjectMapper()
mapper.create_map(A, B, {'last_name': None})

instance_b = mapper.map(A(), B)

In this case, value of A.name will be copied into B.name automatically by the attribute name name. Attribute A.last_name will be not mapped thanks the suppression (lambda function is None).

  1. Case insensitive mapping

Suppose we have class A with attributes Name and Age and class B with attributes name and age and we want to map A to B in a way B.name = A.Name and B.age = A.Age Initialization of the ObjectMapper will be:

mapper = ObjectMapper()
mapper.create_map(A, B)
instance_b = mapper.map(A(), B, ignore_case=True)

In this case, the value of A.Name will be copied into B.name and the value of A.Age will be copied into B.age.

Note: You can find more examples in tests package

Installation

ENJOY IT!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].