Couchbaselite 2.0 Document to/from POJO

I have a User pojo with an embedded Address:
public class User{
String name;
Address address;
public class Address{
String code;
String detail;

I am using Jackson to convert Address/User to/from Document with snippet code:
ObjectMapper m = new ObjectMapper();
Map<String, Object> props = new HashMap<>();
for (String key : document.getKeys()) {
props.put(key, document.getObject(key));

  1. if document is Address type content :

Addreass address = m.convertValue(props, Address.class);
^^^ address fields’ value set correctly

  1. if document is User type content:

User user = m.convertValue(props, User.class);
^^^ user.address will be null , not expected.

With 2.0 there’s a .toMap() function for documents that could be used in conjunction with Jackson. You can find a discussion of how to approach this in this post. (That’s based on 1.x, so it needs slight changes to adapt to 2.0).