title: org.apache.avro.AvroTypeException: Unknown union branch
body: <p>I'm using this Avro schema:</p>
  
  <p><strong>prices-state.avsc</strong></p>
  
  <pre><code>{
      "namespace": "com.company.model",
      "name": "Product",
      "type": "record",
      "fields": [
          {
              "name": "product_id",
              "type": "string"
          },
          {
              "name": "sale_prices",
              "type": {
                  "name": "sale_prices",
                  "type": "record",
                  "fields": [
                      {
                          "name": "default",
                          "type": {
                              "name": "default",
                              "type": "record",
                              "fields": [
                                  {
                                      "name": "order_by_item_price_by_item",
                                      "type": [
                                          "null",
                                          {
                                              "name": "markup_strategy",
                                              "type": "record",
                                              "fields": [
                                                  {
                                                      "name": "type",
                                                      "type": {
                                                          "name": "type",
                                                          "type": "enum",
                                                          "symbols": ["margin", "sale_price"]
                                                      }
                                                  }
                                              ]
                                          }
                                      ]
                                  },
                                  {"name": "order_by_item_price_by_weight", "type": ["null", "string"]},
                                  {"name": "order_by_weight_price_by_weight", "type": ["null", "string"]}
                              ]
                          }
                      }
                  ]
              }
          }
      ]
  }
  </code></pre>
  
  <p>It validates properly on <a href="https://json-schema-validator.herokuapp.com/avro.jsp" rel="noreferrer">this website</a> so I'm assuming the schema is valid.</p>
  
  <p>I'm having issues building a JSON file that should then be encoded using the above schema.</p>
  
  <p>I'm using this JSON for some testing:</p>
  
  <p><strong>test.json</strong></p>
  
  <pre><code>{
      "product_id": "123",
      "sale_prices": {
          "default": {
              "order_by_item_price_by_item": {
                  "markup_strategy": {
                      "type": {"enum": "margin"}
                  }
              },
              "order_by_item_price_by_weight": null,
              "order_by_weight_price_by_weight": null
          }
      }
  }
  </code></pre>
  
  <p>When running <code>java -jar avro-tools-1.8.2.jar fromjson --schema-file prices-state.avsc test.json</code> I get:</p>
  
  <blockquote>
    <p>Exception in thread "main" org.apache.avro.AvroTypeException: Unknown union branch markup_strategy</p>
  </blockquote>
  
  <p>I read <a href="http://avro.apache.org/docs/current/spec.html#json_encoding" rel="noreferrer">here</a> that I have to wrap things inside unions because of JSON Encoding so I tried different combinations but no one seemed to work.</p>