jeudi 2 juillet 2015

Google Gson how to convert a list of tree like nodes

I am saving a list of Nodes which have different attributes such as Type, source, and each node is basically a node in the tree where it can be a node of a subtree. The node is a complex data structure. I need to save a list of such nodes to sqlite database in android. Currently I am trying to save them as Google Gson objects. But it gives me stack overflow error more likely due to the fact that each node can refer to a parent node of same class.

How can I convert this information to Json? Or at-least How can I save this data structure to Sqlite DB? Basically I am trying to save a list of AccessibilityNodeInfo nodes.

List <AccessibilityNodeInfo> list;
String jsonData= Utils.aniToString(recordData);

//anitostring def
Gson g = new Gson();
return g.toJson(traces, listOfAccessibiityNodeInf);

where 
static Type listOfAccessibiityNodeInf=new TypeToken<List<AccessibilityNodeInfo>>(){}.getType();

Aucun commentaire:

Enregistrer un commentaire