title: Deserialize complex JSON to Java, classes nested multiple levels deep
body: <p>I am trying to make the Json output from Cucumber into a single Java object. This contains objects nested four levels deep, and I am having trouble deserializing it. I am presently using Jackson, but open to suggestions.
  Here is my Json code:</p>
  
  <pre><code>{
  "line": 1,
  "elements": [
    {
      "line": 3,
      "name": "Converteren centimeters naar voeten/inches",
      "description": "",
      "id": "applicatie-neemt-maten-in-cm-en-converteert-ze-naar-voet/inch,-en-vice-versa;converteren-centimeters-naar-voeten/inches",
      "type": "scenario",
      "keyword": "Scenario",
      "steps": [
        {
          "result": {
            "duration": 476796588,
            "status": "passed"
          },
          "line": 4,
          "name": "maak Maten-object aan met invoer in \"centimeters\"",
          "match": {
            "arguments": [
              {
                "val": "centimeters",
                "offset": 37
              }
            ],
            "location": "StepDefinition.maakMatenObjectAanMetInvoerIn(String)"
          },
          "keyword": "Given "
        },
        {
          "result": {
            "duration": 36319,
            "status": "passed"
          },
          "line": 5,
          "name": "ik converteer",
          "match": {
            "location": "StepDefinition.converteerMaten()"
          },
          "keyword": "When "
        },
        {
          "result": {
            "duration": 49138,
            "status": "passed"
          },
          "line": 6,
          "name": "uitvoer bevat maat in \"voeten/inches\"",
          "match": {
            "arguments": [
              {
                "val": "voeten/inches",
                "offset": 23
              }
            ],
            "location": "StepDefinition.uitvoerBevatMaatIn(String)"
          },
          "keyword": "Then "
        }
      ]
    },
    {
      "line": 8,
      "name": "Converteren voeten/inches naar centimeters",
      "description": "",
      "id": "applicatie-neemt-maten-in-cm-en-converteert-ze-naar-voet/inch,-en-vice-versa;converteren-voeten/inches-naar-centimeters",
      "type": "scenario",
      "keyword": "Scenario",
      "steps": [
        {
          "result": {
            "duration": 84175,
            "status": "passed"
          },
          "line": 9,
          "name": "maak Maten-object aan met invoer in \"voeten/inches\"",
          "match": {
            "arguments": [
              {
                "val": "voeten/inches",
                "offset": 37
              }
            ],
            "location": "StepDefinition.maakMatenObjectAanMetInvoerIn(String)"
          },
          "keyword": "Given "
        },
        {
          "result": {
            "duration": 23928,
            "status": "passed"
          },
          "line": 10,
          "name": "ik converteer",
          "match": {
            "location": "StepDefinition.converteerMaten()"
          },
          "keyword": "When "
        },
        {
          "result": {
            "duration": 55547,
            "status": "passed"
          },
          "line": 11,
          "name": "uitvoer bevat maat in \"centimeters\"",
          "match": {
            "arguments": [
              {
                "val": "centimeters",
                "offset": 23
              }
            ],
            "location": "StepDefinition.uitvoerBevatMaatIn(String)"
          },
          "keyword": "Then "
        }
      ]
    }
  ],
  "name": "Applicatie neemt maten in cm en converteert ze naar voet/inch, en vice versa",
  "description": "",
  "id": "applicatie-neemt-maten-in-cm-en-converteert-ze-naar-voet/inch,-en-vice-versa",
  "keyword": "Feature",
  "uri": "sample.feature"
  }
  </code></pre>
  
  <p>I have tried a number of different approaches. First I used nested inner classes, but it appeared you had to make them static, which I feared would not work since I have multiple instances of the same object within one (multiple "element"-objects in the root, for example). Then I tried putting them in separate classes, with Json annotations. Here's where that got me (omitting setters):</p>
  
  <pre><code>public class CucumberUitvoer {
      private String name;
      private String description;
      private String id;
      private String keyword;
      private String uri;
      private int line;
      @JsonProperty("elements")
      private List&lt;FeatureObject&gt; elements;
  
      public CucumberUitvoer(){}
  }
  
  public class FeatureObject {
      private String name;
      private String description;
      private String id;
      private String type;
      private String keyword;
      private int line;
      @JsonProperty("steps")
      private List&lt;StepObject&gt; steps;
  
      public FeatureObject() {
      }
  }
  
  public class StepObject {
      @JsonProperty("result")
      private ResultObject result;
      private String name;
      private String given;
      private String location;
      private String keyword;
      private int line;
      @JsonProperty("match")
      private MatchObject match;
  
      public StepObject(){}
  }
  
  public class ResultObject {
      private int duration;
      private String status;
  
      public ResultObject(){}
  }
  
  public class MatchObject {
      @JsonProperty("arguments")
      private List&lt;ArgumentObject&gt; arguments;
      private String location;
  
      public MatchObject(){}
  }
  
  public class ArgumentObject {
      private String val;
      private String offset;
  
      public ArgumentObject(){}
  }
  </code></pre>
  
  <p>For clarification, <a href="https://i.stack.imgur.com/vfKhj.png" rel="noreferrer">here</a>'s a class diagram of how the nesting works.</p>
  
  <p>This solution gives me the following error: </p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of nl.icaprojecten.TestIntegratieQuintor.JSONInterpreter.CucumberUitvoer out of START_ARRAY token
  </code></pre>
  
  <p>Here is the code doing the actual mapping:</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
      mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  
      CucumberUitvoer obj1 = null;
      try {
          obj1 = mapper.readValue(json, CucumberUitvoer.class);
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>Is there a quick fix to this approach to make it work, or should I try something entirely different?</p>