# Deserialize a JSON Array to a Singly Linked List

We know that Jackson is very convenient to deserialize a JSON string into a ArrayList, HashMap or POJO object.

But how to deserialize a JSON array, such as [1,2,3,4,5] to a singly linked list?

The definition of singly linked list is as follows:

Well, the solution is quite simpler than I expected: Just make SinglyLinkedListNode implement java.util.List or java.util.Collection , Jackson will automatically deserialize it!

This idea comes from Tatu Saloranta, the discussion post is here, special thanks to him!

Here is the complete code of SinglyLinkedListNode:

Then comes with the unit tests:

## Related Posts

Deserialize a JSON String to a Binary Tree