public class Jackson2HashMapper extends Object implements HashMapper<Object,String,Object>
ObjectMapper based HashMapper implementation that allows flattening. Given an entity Person
with an Address like below the flattening will create individual hash entries for all nested properties and
resolve complex types into simple types, as far as possible.
Flattening requires all property names to not interfere with JSON paths. Using dots or brackets in map keys or as
property names is not supported using flattening. The resulting hash cannot be mapped back into an Object.
class Person {
String firstname;
String lastname;
Address address;
Date date;
LocalDateTime localDateTime;
}
class Address {
String city;
String country;
}
| Hash field | Value |
|---|---|
| firstname | Jon |
| lastname | Snow |
| address | { "city" : "Castle Black", "country" : "The North" } |
| date | 1561543964015 |
| localDateTime | 2018-01-02T12:13:14 |
| Hash field | Value |
|---|---|
| firstname | Jon |
| lastname | Snow |
| address.city | Castle Black |
| address.country | The North |
| date | 1561543964015 |
| localDateTime | 2018-01-02T12:13:14 |
| Constructor and Description |
|---|
Jackson2HashMapper(boolean flatten)
Creates new
Jackson2HashMapper with default ObjectMapper. |
Jackson2HashMapper(com.fasterxml.jackson.databind.ObjectMapper mapper,
boolean flatten)
Creates new
Jackson2HashMapper. |
public Jackson2HashMapper(boolean flatten)
Jackson2HashMapper with default ObjectMapper.flatten - public Jackson2HashMapper(com.fasterxml.jackson.databind.ObjectMapper mapper,
boolean flatten)
Jackson2HashMapper.mapper - must not be null.flatten - public Map<String,Object> toHash(Object source)
HashMapperobject to a map that can be used with Redis hashes.toHash in interface HashMapper<Object,String,Object>public Object fromHash(Map<String,Object> hash)
HashMapperhash (map) to an object.fromHash in interface HashMapper<Object,String,Object>Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.