Orika mapper

搜索:orika mapper fieldAToB nested field

https://orika-mapper.github.io/orika-docs/mappings-via-classmapbuilder.html

https://stackoverflow.com/questions/24445201/custom-mapping-with-orika

问题:
对象中嵌套对象,mapper 到另外一个对象。

The same pattern may be applied to refer to values in a Map by listing the key’s value within brackets, but the key value should be quoted (double or single); assuming that the ‘nameParts’ property from the previous example were defined as a Map, we could reference individual key values like so:

mapperFactory.classMap(BasicPerson.class, BasicPersonDto.class)
   .field("nameParts['first']", "firstName")
   .field("nameParts[\"last\"]", "lastName")
   .register();

对象中嵌套数组,mapper到另外一个对象

mapperFactory.classMap(BasicPerson.class, BasicPersonDto.class)
   .field("nameParts[0]", "firstName")
   .field("nameParts[1]", "lastName")
   .register();

你可能感兴趣的:(Orika mapper)