title: How to specify coder for KV<Boolean, Map<String, Object>> in google Beam/dataflow
body: <p>I have a table that is described in the json file and based on that I want to create a collection as a sideInput later on. </p>
  
  <pre class="lang-java prettyprint-override"><code>PCollection&lt;KV&lt;Boolean, Map&lt;String, Object&gt;&gt;&gt; pC = p_jsonstring
      .apply("create ...", MapElements.via( (String input) -&gt; {                                                                               
        try {
          ObjectMapper mapper = new ObjectMapper();
          Map&lt;String, Object&gt; mytable =
              mapper.readValue(input, new TypeReference&lt;Map&lt;String, Object&gt;&gt;(){});
          Boolean key = (Boolean) mytable.get("mykey");
          return KV.of(key, mytable);
        } catch (IOException e) {
          e.printStackTrace();
          return null;
        }
      }).withOutputType(new TypeDescriptor&lt;KV&lt;Boolean, Map&lt;String, Object&gt;&gt;&gt;() {}));
  </code></pre>
  
  <p>When running it, I have the following error messages:</p>
  
  <blockquote>
    <p>SEVERE: Unable to return a default Coder for create KV../Map.out [PCollection]. Correct one of the following root causes:
      No Coder has been manually specified;  you may do so using .setCoder().
      Inferring a Coder from the CoderRegistry failed: Unable to provide a default Coder for org.apache.beam.sdk.values.KV>. Correct one of the following root causes:
      Building a Coder using a registered CoderFactory failed: Cannot provide coder for parameterized type org.apache.beam.sdk.values.KV>: Unable to provide a default Coder for java.util.Map. Correct one of the following root causes:
      Building a Coder using a registered CoderFactory failed: Cannot provide coder for parameterized type java.util.Map: Unable to provide a default Coder for java.lang.Object. Correct one of the following root causes:
      Building a Coder using a registered CoderFactory failed: Cannot provide coder based on value with class java.lang.Object: No CoderFactory has been registered for the class.
      Building a Coder from the @DefaultCoder annotation failed: Class java.lang.Object does not have a @DefaultCoder annotation.</p>
  </blockquote>
  
  <p>I think the issue is mainly related to <code>Object</code> in <code>Map&lt;String, Object&gt;</code>, but in my case the mapping value is only determined at the runtime when reading the json string from the file. The Object type can be string, number or boolean.</p>
  
  <p>Any suggestions?</p>