Google Gson how to convert tree list as nodes

I keep a list of nodes that have different attributes like Type, source and each node is basically a node in the tree where it can be a node of a subtree. node is a complex data structure. I need to store a list of such nodes in a sqlite database in android. I am currently trying to save them as Google Gson Objects. But this rather leads to an error due to the fact that each node can refer to a parent node of the same class.

How can I convert this information to Json? Or at least how to store this data structure in Sqlite DB? Basically I'm trying to keep 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();

      

+3


source to share





All Articles