Marcos de las Heras Marcos de las Heras - 1 year ago 113
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 /

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download