Remove '@class' in XStream for Java primitive types

319 views Asked by At

I have this field in a POJO that is serialized into JSON:

@XStreamAlias("tags")
List<String> tags;

My problem is that the output looks like this:

"tags": [
      {
        "@class": "linked-list",
        "string": [
          "test",
          "test2"
        ]
      }
    ],

In what way that the output would look like this:

"tags": [
          "test",
          "test2"
        ],

Just like this.

1

There are 1 answers

0
quarks On BEST ANSWER

The solution is to add @XStreamImplicit annotation:

@XStreamImplicit(itemFieldName="tags")
List<String> tags;