gt:         JSONObject result = new JSONObject(gson.toJson(cepl));
context: /**
   * Cerberus Copyright (C) 2013 - 2017 cerberustesting
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This file is part of Cerberus.
   *
   * Cerberus is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * Cerberus is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with Cerberus.  If not, see <http://www.gnu.org/licenses/>.
   */
  package org.cerberus.servlet.crud.countryenvironment;
  
  import com.google.gson.Gson;
  import java.io.IOException;
  import java.util.List;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  import org.cerberus.crud.entity.CountryEnvironmentParameters;
  import org.cerberus.engine.entity.MessageEvent;
  import org.cerberus.crud.service.ICountryEnvironmentParametersService;
  import org.cerberus.enums.MessageEventEnum;
  import org.cerberus.exception.CerberusException;
  import org.cerberus.util.ParameterParserUtil;
  import org.cerberus.util.answer.AnswerItem;
  import org.cerberus.util.answer.AnswerList;
  import org.cerberus.util.answer.AnswerUtil;
  import org.cerberus.util.servlet.ServletUtil;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import org.owasp.html.PolicyFactory;
  import org.owasp.html.Sanitizers;
  import org.springframework.context.ApplicationContext;
  import org.springframework.web.context.support.WebApplicationContextUtils;
  
  /**
   *
   * @author cerberus
   */
  @WebServlet(name = "ReadCountryEnvironmentParameters", urlPatterns = {"/ReadCountryEnvironmentParameters"})
  public class ReadCountryEnvironmentParameters extends HttpServlet {
  
      private static final Logger LOG = LogManager.getLogger(ReadCountryEnvironmentParameters.class);
      private ICountryEnvironmentParametersService cepService;
      private final String OBJECT_NAME = "ReadCountryEnvironmentParameters";
  
      /**
       * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
       * methods.
       *
       * @param request servlet request
       * @param response servlet response
       * @throws ServletException if a servlet-specific error occurs
       * @throws IOException if an I/O error occurs
       * @throws org.cerberus.exception.CerberusException
       */
      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException, CerberusException {
          String echo = request.getParameter("sEcho");
          ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
          PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
  
          response.setContentType("application/json");
          response.setCharacterEncoding("utf8");
  
          // Calling Servlet Transversal Util.
          ServletUtil.servletStart(request);
          
          // Default message to unexpected error.
          MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
          msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
  
          /**
           * Parsing and securing all required parameters.
           */
          String system = policy.sanitize(request.getParameter("system"));
          String country = policy.sanitize(request.getParameter("country"));
          String environment = policy.sanitize(request.getParameter("environment"));
          String application = policy.sanitize(request.getParameter("application"));
  
          // Global boolean on the servlet that define if the user has permition to edit and delete object.
          boolean userHasPermissions = request.isUserInRole("IntegratorRO");
  
          // Init Answer with potencial error from Parsing parameter.
          AnswerItem answer = new AnswerItem<>(msg);
  
          try {
              JSONObject jsonResponse = new JSONObject();
              if (1 == 1) {
                  answer = findCountryEnvironmentParametersList(request.getParameter("system"), request.getParameter("country"), request.getParameter("environment"), request.getParameter("application"), appContext, userHasPermissions, request);
                  jsonResponse = (JSONObject) answer.getItem();
              }
              jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());
              jsonResponse.put("message", answer.getResultMessage().getDescription());
              jsonResponse.put("sEcho", echo);
  
              response.getWriter().print(jsonResponse.toString());
  
          } catch (JSONException e) {
              LOG.warn(e);
              //returns a default error message with the json format that is able to be parsed by the client-side
              response.setContentType("application/json");
              response.getWriter().print(AnswerUtil.createGenericErrorAnswer());
          }
      }
  
  // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
      /**
       * Handles the HTTP <code>GET</code> method.
       *
       * @param request servlet request
       * @param response servlet response
       * @throws ServletException if a servlet-specific error occurs
       * @throws IOException if an I/O error occurs
       */
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          try {
              processRequest(request, response);
          } catch (CerberusException ex) {
              LOG.warn(ex);
          }
      }
  
      /**
       * Handles the HTTP <code>POST</code> method.
       *
       * @param request servlet request
       * @param response servlet response
       * @throws ServletException if a servlet-specific error occurs
       * @throws IOException if an I/O error occurs
       */
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          try {
              processRequest(request, response);
          } catch (CerberusException ex) {
              LOG.warn(ex);
          }
      }
  
      /**
       * Returns a short description of the servlet.
       *
       * @return a String containing servlet description
       */
      @Override
      public String getServletInfo() {
          return "Short description";
      }// </editor-fold>
  
      private AnswerItem<JSONObject> findCountryEnvironmentParametersList(String system, String country, String environment, String application, ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {
  
          AnswerItem<JSONObject> item = new AnswerItem<>();
          JSONObject object = new JSONObject();
          cepService = appContext.getBean(ICountryEnvironmentParametersService.class);
  
          int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));
          int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));
          /*int sEcho  = Integer.valueOf(request.getParameter("sEcho"));*/
  
          String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");
          int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "1"));
          String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "ID,system,country,Environment,Build,Revision,Chain,Disable,datecre,creator");
          String columnToSort[] = sColumns.split(",");
          String columnName = columnToSort[columnToSortParameter];
          String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "asc");
          AnswerList<CountryEnvironmentParameters> resp = cepService.readByVariousByCriteria(system, country, environment, application, startPosition, length, columnName, sort, searchParameter, "");
  
          JSONArray jsonArray = new JSONArray();
          if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values
              for (CountryEnvironmentParameters cepl : (List<CountryEnvironmentParameters>) resp.getDataList()) {
                  jsonArray.put(convertCountryEnvParamtoJSONObject(cepl));
              }
          }
  
          object.put("hasPermissions", userHasPermissions);
          object.put("contentTable", jsonArray);
          object.put("iTotalRecords", resp.getTotalRows());
          object.put("iTotalDisplayRecords", resp.getTotalRows());
  
          item.setItem(object);
          item.setResultMessage(resp.getResultMessage());
          return item;
  
      }
  
      private JSONObject convertCountryEnvParamtoJSONObject(CountryEnvironmentParameters cepl) throws JSONException {
          Gson gson = new Gson();
  