1

Is there any json library for android which can manage circular reference ? I need to serialize one object which contains list of objects, where every object from list can contains list of objects of self type.

for example

class item{
LinkedList<item> list
}

class container{
LinkedList<item> list;
}

I have tried with Gson ( and Xtreme to xml ) but it doesn't work.

Damir
  • 54,277
  • 94
  • 246
  • 365

1 Answers1

1

Android will run whatever Java library you choose.

AFAIK, Gson doesn't handle circular references, but Jackson and XStream do.

Check out these threads for further info:

How to solve circular reference in json serializer caused by hibernate bidirectional mapping?

Jackson Vs. Gson

UPD But you're probably better off adding ignore annotations to those back references.

Community
  • 1
  • 1
Ivan Bartsov
  • 19,664
  • 7
  • 61
  • 59