title: How to exclude in JSON property of an object (inside output class)?
body: <p>Let's say I an output class that will be converted to JSON:</p>
  
  <p><strong>StudentSummary.java</strong></p>
  
  <pre><code>public class StudentSummary {
  
      private StudentList studentList;
  
      // getters setters
  }
  </code></pre>
  
  <p>and </p>
  
  <p><strong>StudentList.java</strong></p>
  
  <pre><code>public class StudentList {
  
      private int numberOfStudents;
      private int totalExpenditures;
      private List&lt;Student&gt; students;
  
      // getters setters
  }
  </code></pre>
  
  <p>After making a service call, I get this JSON output:</p>
  
  <pre><code>{ 
   "studentSummary": {
       "studentList": {
           "numberOfStudents": 500,
           "totalExpenditures": 250000,
           "students": [ /* students listed */ ]
       }
  }
  </code></pre>
  
  <p>I want to <strong>exclude</strong> from JSON the <code>studentList</code> in the <code>StudentSummary</code> class:</p>
  
  <pre><code>{ 
   "studentSummary": {
       "studentList": {
           "numberOfStudents": 500,
           "totalExpenditures": 250000
        }
    }
  }
  </code></pre>
  
  <p>I've tried using (in the StudentSummary output class) <code>@JsonIgnore</code> and <code>@JsonProperties</code> , by specifying to only exclude <code>"studentList.students"</code>, but that doesn't do anything.</p>
  
  <p>EDIT: Further clarification, for why I couldn't do the changes inside the StudentList class, it's because it is used by another service and the service with StudentSummary class is of a different service, so I can only make the changes inside the latter class, without modifying the previous service.</p>