private static void processJsonToTree ( final TreeItemIdNode parentNode , final JsonObject json ) { String id = json . getAsJsonPrimitive ( "id" ) . getAsString ( ) ; JsonPrimitive expandableJson = json . getAsJsonPrimitive ( "expandable" ) ; TreeItemIdNode node = new TreeItemIdNode ( id ) ; if ( expandableJson != null && expandableJson . getAsBoolean ( ) ) { node . setHasChildren ( true ) ; } parentNode . addChild ( node ) ; JsonArray children = json . getAsJsonArray ( "items" ) ; if ( children != null ) { for ( int i = 0 ; i < children . size ( ) ; i ++ ) { JsonObject child = children . get ( i ) . getAsJsonObject ( ) ; processJsonToTree ( node , child ) ; } } }
Iterate over the JSON objects to create the tree structure .