Marcos de las Heras Marcos de las Heras - 2 months ago 34
Java Question

Convert List<Item> to json

I am having a List like following,

List<Item> EquipmentData = SAPEquipment.getByFilter(filter);

That item is the result I'm getting from SAP ("")

My problem is that i need to convert that List to Json format. I've been reading some examples and tried using Gson like that:

Gson gson = new Gson();

also tried with just one item


The error reported is the following one:


I cannot modify that List so I will need a proper way to convert it.

Any tip will be highly appreciated

EDIT : Added Item Class link (

EDIT2: Added full stacktrace /


The reason for Stackoverflow might be because of the recursive mappings in your Item class. One way to fix this is to iterate through the EquipmentData list and set your return object(DTO) then convert the DTO using GSON.