title: Jackson JSON serializer returns extra collection name
body: <p>I have an list of things that I return as a jackson list. What I would like is this:</p>
  
  <pre><code>"things": { [
          {
            "id": "1234",
  </code></pre>
  
  <p>..list of students</p>
  
  <p>but currently, I am getting this:</p>
  
  <pre><code>"things": {
        "HashSet": [
          {
            "id": "1234",
  </code></pre>
  
  <p>I am using a JsonSerializer>, which is why it adds the HashSet field. I tried adding a json property on the field, but its not allowed since it is a local variable.</p>
  
  <p>I am currently using the jackson library and have looked into:</p>
  
  <p><a href="https://stackoverflow.com/questions/9741134/jackson-annotation-how-to-rename-element-names">Jackson annotation - How to rename element names?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15936680/how-to-rename-root-key-in-json-serialization-with-jackson">How to rename root key in JSON serialization with Jackson</a></p>
  
  <p>but they seem to have a different issue altogether. Any ideas? Thanks!</p>
  
  <p>Edit:</p>
  
  <p>Added the class implementations. Note that I call owner, that contains Things. Also, my jpa annotations are there as well. Thanks.</p>
  
  <pre><code>@Entity @Table(name = "owner") 
  public class Owner extends BaseEntity implements Persistence {
  
  @Column 
  private String name;
  
  @Column 
  private String description;
  
  @Column 
  private Integer capacity;
  
  @Column
  @JsonSerialize(using = ThingSerializer.class)
  @JsonProperty("things")
  @ManyToMany(fetch = FetchType.EAGER, mappedBy = "owners")
  private Set&lt;Thing&gt; tihngs = new HashSet&lt;&gt;();
  
  
  public class ThingSerializer extends JsonSerializer&lt;Set&lt;Thing&gt;&gt; {
  
  @Override public void serialize(Set&lt;Thing&gt; thingSet, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws
                                                                                                                             IOException,
                                                                                                                             JsonProcessingException {
  
      Set&lt;Thing&gt; things = new HashSet&lt;&gt;();
  
      thingSet.forEach(thing -&gt; {
  
          Thing t = new Thing();
  
          t.setCreatedBy(thing.getCreatedBy());
          t.setCreationDate(thing.getCreationDate());
          t.setId(thing.getId());
          t.setDateModified(thing.getDateModified());
          t.setModifiedBy(thing.getModifiedBy());
          t.setStatus(thing.getStatus());
  
          things.add(s);
      });
  
      jsonGenerator.writeObject(things);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Thing Entity</p>
  
  <pre><code>@Entity
  @Table(name = "thing")
  public class Thing extends BaseEntity implements Persistence {
  
  private static final long serialVersionUID = 721739537425505668L;
  
  private String createdBy;
  private Date creationDate;
  .
  .
  .
  
  
  
  
  @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
  @JoinTable(name = "ThingOwner", joinColumns = @JoinColumn(name = "thing_id") , inverseJoinColumns = @JoinColumn(name = "owner_id") )
  private Set&lt;Owner&gt; owners = new HashSet&lt;&gt;();
  </code></pre>