title: Deserialize json file with dynamic fields into class with java
body: <p>We have a JSON file providing us with data that needs to be loaded in memory, however I'm having a lot of trouble parsing the file as it does not use mapping of fields like I have seen classically:</p>
  
  <pre><code>{
    "1er":{
      "baccalaureat": [
        {
          "prog": "genie logiciel",
          "limite": 30
        },
        {
          "prog": "genie civil",
          "limite": 15
        },
        {
          "prog": "genie electrique",
          "limite": 25
        },
        {
          "prog": "Medecine",
          "limite": 34
        },
        {
          "prog": "actuariat",
          "limite": 25
        }
      ]
    },
    "2e":{
      "maitrise": [
        {
          "prog": "informatique",
          "limite": 25
        }
      ]
    },
    "3e":{
      "doctorat": [
        {
          "prog": "informatique",
          "limite": 21
        }
      ]
    }
  }
  </code></pre>
  
  <p>I use to deal with JSON files with "property" : "value" and I was hoping to be able to use jackson annotations. I've tried a test class shaped like this:</p>
  
  <pre><code>public class ClassOne {
      @JsonProperty
      public String Level;
  
      @JsonProperty
      public String[] programs;
  }
  </code></pre>
  
  <p>But alas it does not working, throwing a mismatchedInputException. Of course, but I don't know how to map the properties, then:</p>
  
  <pre><code>private ObjectMapper objectMapper;
      private ProgramLimitService programLimitService;
  
      public ProgramLimitsLoader() {
          objectMapper = new ObjectMapper();
      }
  
      private static List&lt;String&gt; values = new ArrayList&lt;&gt;();
  
      public void load(String path) {
          File file = new File(path);
  
          ClassOne[] classes;
  
          try {
              classes = objectMapper.readValue(file, ClassOne[].class);
          } catch (IOException e) {
              throw new FileCantBeOpenException(e.getMessage());
          }
      }
  </code></pre>
  
  <p>I feel like it's because the structure of my class while I'm deserializing is wrong, but I can't put the finger on the problem.</p>