title: Json String to Java Object Avro
body: <p>I am trying to convert a Json string into a generic Java Object, with an Avro Schema.</p>
  
  <p>Below is my code.</p>
  
  <pre><code>String json = "{\"foo\": 30.1, \"bar\": 60.2}";
  String schemaLines = "{\"type\":\"record\",\"name\":\"FooBar\",\"namespace\":\"com.foo.bar\",\"fields\":[{\"name\":\"foo\",\"type\":[\"null\",\"double\"],\"default\":null},{\"name\":\"bar\",\"type\":[\"null\",\"double\"],\"default\":null}]}";
  
  InputStream input = new ByteArrayInputStream(json.getBytes());
  DataInputStream din = new DataInputStream(input);
  
  Schema schema = Schema.parse(schemaLines);
  
  Decoder decoder = DecoderFactory.get().jsonDecoder(schema, din);
  
  DatumReader&lt;Object&gt; reader = new GenericDatumReader&lt;Object&gt;(schema);
  Object datum = reader.read(null, decoder);
  </code></pre>
  
  <p>I get "org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_NUMBER_FLOAT" Exception.</p>
  
  <p>The same code works, if I don't have unions in the schema. 
  Can someone please explain and give me a solution.</p>