title: Java Jackson, Marshalling class with Map<String, Object> without access to the class code base
body: <p>I'm trying to marshall (serialize) class using Jackson mapper.
  Class has Map property. Property has to have some kind of serialization... everything i got was a serialized byte stream or badly serialized map.toString().</p>
  
  <p>I've tried using mixins or setup Jackson mapper... without any help. </p>
  
  <p>com.fasterxml.jackson 2.8.11
  com.rabbitmq.client   5.4.3</p>
  
  <p>My Code:</p>
  
  <pre class="lang-java prettyprint-override"><code>private RawMessage parseMetadata(RawMessage rawMessage, Envelope envelope, AMQP.BasicProperties properties) throws JsonProcessingException {
      ObjectMapper mapper = new ObjectMapper();
      mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
      mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  
  
      JsonNode rootNode = mapper.createObjectNode();
  
      JsonNode message = mapper.valueToTree(new String(rawMessage.getPayload()));
      ((ObjectNode) rootNode).set("message", message);
  
      JsonNode envelopeNode = mapper.valueToTree(envelope);
      ((ObjectNode) rootNode).set("envelope", envelopeNode);
  
      JsonNode propertiesNode = mapper.valueToTree(properties);
      ((ObjectNode) rootNode).set("properties", propertiesNode);
  
      return new RawMessage(mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(rootNode));
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{
    "properties": {
      "bodySize": 0,
      "headers": {
        "connection_name": {
          "bytes": "MTcyLjE5LjAuMTo0NTgzNiAtPiAxNzIuMTkuMC40OjU2NzI=",
          "stream": {
            "in": { "buf": "MTcyLjE5LjAuMTo0NTgzNiAtPiAxNzIuMTkuMC40OjU2NzI=", "pos": 0, "mark": 0, "count": 35 },
            "bytearr": "A...",
            "chararr": "\u0000...",
            "readBuffer": "AAAAAAAAAAA="
          }
        },
        "timestamp_in_ms": 1565957758662,
        "protocol": {
          "bytes": "ezAsOSwxfQ==",
          "stream": {
            "in": { "buf": "ezAsOSwxfQ==", "pos": 0, "mark": 0, "count": 7 },
            "bytearr": "AAA...",
            "chararr": "\u0000\u0000\...",
            "readBuffer": "AAAAAAAAAAA="
          }
        },...
        },
        "ssl": false
      },
      "deliveryMode": 2,
      "timestamp": 1565957758000,
      "classId": 60,
      "className": "basic"
    }
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>class BasicProperties extends com.rabbitmq.client.impl.AMQBasicProperties {
          private String contentType;
          private String contentEncoding;
          private Map&lt;String,Object&gt; headers; &lt;--- 
          private Integer deliveryMode;
          private Integer priority;
          private String correlationId;
          private String replyTo;
          private String expiration;
          private String messageId;
          private Date timestamp;
          private String type;
          private String userId;
          private String appId;
          private String clusterId;
  ...}
  </code></pre>
  
  <p>Reproduction:</p>
  
  <pre class="lang-java prettyprint-override"><code>import com.rabbitmq.client.AMQP;
  
  Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
  byte[] test =  "test".getBytes();
  map.put("test", test);
  AMQP.BasicProperties prop = new AMQP.BasicProperties(null, null, map,null,null,null,null,null,null,null,null,null,null,null);
  
  ObjectMapper objectMapper = new ObjectMapper();
  objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
  objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  
  JsonNode root = objectMapper.createObjectNode();
  
  JsonNode propertiesN = objectMapper.valueToTree(prop);
  ((ObjectNode) root).set("properties", propertiesN);
  
  LOG.info(root.toString());
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{
    "properties": {
      "bodySize": 0,
      "headers": { "test": "dGVzdA==" },
      "classId": 60,
      "className": "basic"
    }
  }
  
  </code></pre>
  
  <p>three dots means there's more of it. It's too long. Too many byte streams.</p>
  
  <p>I expect the output of map would be -> key: String </p>
  
  <p>I want to output look like his -> properties.headers.test: "test"</p>
  
  <p>Without any annotation of AMQP.BasicProperties class.</p>
  
  <p>I think that Jacksons Mixins should be the way to do it.</p>