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
java json android gson sqlite


source to share


No one has answered this question yet

Check out similar questions:

3799
How do I read / convert an InputStream to a string in Java?
2853
How can I convert String to int in Java?
1415
How do I convert the stack trace to a string?
1031
How can I list tables in a SQLite database file that was opened with ATTACH?
930
Converting an array to a list in Java
589
How do I convert a map to a list in Java?
438
Java tree data structure?
397
Gson: How to exclude certain fields from serialization without annotations
279
Google Gson - deserialize list <class> object? (general type)
256
Gson: Directly convert String to JsonObject (no POJO)



All Articles
Loading...
X
Show
Funny
Dev
Pics