question: @ Override protected void doGet ( SlingHttpServletRequest request , SlingHttpServletResponse response ) throws ServletException , IOException { final PrintWriter writer = response . getWriter ( ) ; response . setCharacterEncoding ( CharEncoding . UTF_8 ) ; response . setContentType ( "application/json" ) ; List < JcrPackage > packages = packageService . getPackageList ( request ) ; try { JSONArray jsonArray = new JSONArray ( ) ; for ( JcrPackage jcrPackage : packages ) { final JSONObject json = getJsonFromJcrPackage ( jcrPackage ) ; jsonArray . put ( json ) ; } response . setStatus ( SlingHttpServletResponse . SC_OK ) ; writer . write ( jsonArray . toString ( ) ) ; } catch ( JSONException | RepositoryException e ) { LOGGER . error ( "Could not write JSON" , e ) ; response . setStatus ( SlingHttpServletResponse . SC_INTERNAL_SERVER_ERROR ) ; } }
target:  Return all packages on a GET request in order of newest to oldest.