title: How to read JSON file of objects into a list in Java with Jackson
body: <pre><code> public class Town {    
  
      private Person p;
  
      private String hello;
      private long number;
  }
  
  public class Person {
  
      private String firstName;
      private double legs;
      private String lastName;
  }
  </code></pre>
  
  <p>I am trying to write the Town class to JSON using the below code</p>
  
  <pre><code>ObjectMapper mapper = new ObjectMapper();
  ObjectWriter writer = mapper.writer(new DefaultPrettyPrinter());
  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true)));
   writer.writeValue(out, townobj);
  </code></pre>
  
  <p>Which produces Json like this.</p>
  
  <pre><code>{
    "p" : {
      "firstName" : "John",
      "amount" : 6860.0,
      "lastName" : "Smith"
    },
    "hello" : "qwiejiowcqnio",
    "number" : 1380.0
  }
  
  {
    "p" : {
      "firstName" : "Sam",
      "amount" : 623460.0,
      "lastName" : "Smith"
    },
    "hello" : "qwiej2342io",
    "number" : 1330.0
  }
  </code></pre>
  
  <p>How do I read such an output produced from nested objects into Java with jackson?</p>