title: Jackson serialize a subset of a map
body: <p>I have a map which I want to serialize using Jackson but only want to serialize a subset of it.  Say I have a simple map as follows:</p>
  
  <pre><code>final Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
  map.put("key 1", "value 1");
  map.put("key 2", "value 2");
  map.put("_internal key 1", "value 3");
  map.put("_internal key 2", "value 4");
  </code></pre>
  
  <p>Then when serializing this I want to filter out any item whose key starts with <code>_</code>, so that the serialized representation would be <code>{'key 1': 'value 1','key 2': 'value 2'}</code>.</p>
  
  <p>I started looking at <code>@JsonFilter</code> but can't find any examples beyond very simplistic ones against basic types and nothing which appears to help with this more advanced type of filtering.</p>
  
  <p>What's the best way to provide this custom serialization?</p>
  
  <p>This is using Jackson 2.4, in case it matters.</p>