Store query JCR Sql2 in a list or an array
hello I have this query and I would like to be able to store this query in a list or an array to carry out some processes with them here is the one that I have
resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
Session session = resourceResolver.adaptTo(Session.class);
Workspace workspace = session.getWorkspace();
QueryManager queryManager = workspace.getQueryManager();
Query query = queryManager.createQuery("SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/projectGames/games])",Query.JCR_SQL2);
QueryResult result = query.execute();
NodeIterator nodeIterator = result.getNodes();
JSONArray arrayResult = new JSONArray();
JSONArray arrayGame = new JSONArray();
arrayResult.put(nodeIterator);
JSONObject game = new JSONObject();
for (int i = 0 ; i < arrayResult.length() ; i++)
{
trying to store the data in json array
}
or if you could give me an example of a better way to do it, I hope you have made me understand and I appreciate all the help because I am a little new in the sling issues