Étienne Miret
Étienne Miret

Reputation: 6660

Are Jackson's lists guaranteed to be mutable?

When I deserialize a JSON array to a Java List using Jackson 2.8.7, I can see that I get an ArrayList (which is mutable). Is this guaranteed? Or might it change in some future version?

I couldn't find any information about this in Jackson documentation, which bothers me, because if it is indeed unspecified, then I guess there is no guaranty.

Upvotes: 1

Views: 670

Answers (1)

Mureinik
Mureinik

Reputation: 311883

As you speculated, Jackson gives no guarantee its deserialized list will be mutable, by way of omission - since it isn't explicitly stated that such a list will be mutable, you cannot assume this isn't just an implementation detail.

If you rely on this behavior you do so at your own risk that it may break in some future version, or even in an edge-case of the version you're using (e.g., an empty list or a list with a single element).

Upvotes: 2

Related Questions