title: Why does Gson add slashes to String
body: <p>I implemented a simple HttpServlet. The servlet takes requests and calls a third party API to get the data, and then sends data back in response. However, in the response, JSON adds too many slashes.</p>
  
  <p>Does anyone know why?<br>
  Below is my code.</p>
  
  <pre><code>public class InstitutionServlet extends HttpServlet {
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          Gson gson = new Gson();
  
          String city = request.getParameter("city");
          String apiUrl = "https://inventory.data.gov/api/action/datastore_search?resource_id=38625c3d-5388-4c16-a30f-d105432553a4&amp;q=" + city;
          String data = getInstitutions(apiUrl);
  
          response.setContentType("application/json");
          PrintWriter pw = response.getWriter();
          gson.toJson(data, pw);
      }
  
      //Get institutions data from API url.
      private String getInstitutions(String apiUrl) {
          StringBuilder institutions = new StringBuilder();
  
          try {
              URL url = new URL(apiUrl);
              URLConnection urlConnection = url.openConnection();
              BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
              String line;
  
              while ((line = bufferedReader.readLine()) != null) {
                  institutions.append(line).append("\n");
              }
  
              bufferedReader.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          return institutions.toString();
      }
  }
  </code></pre>
  
  <p>Original data from the API <a href="https://inventory.data.gov/api/action/datastore_search?resource_id=38625c3d-5388-4c16-a30f-d105432553a4&amp;q=whatever" rel="nofollow noreferrer">https://inventory.data.gov/api/action/datastore_search?resource_id=38625c3d-5388-4c16-a30f-d105432553a4&amp;q=whatever</a>:</p>
  
  <pre><code>{
      "help": "https://inventory.data.gov/api/3/action/help_show?name=datastore_search",
      "success": true,
      "result": {
          "resource_id": "38625c3d-5388-4c16-a30f-d105432553a4",
          "q": "whatever",
          "records": [],
          "_links": {
              "start": "/api/action/datastore_search?q=whatever&amp;resource_id=38625c3d-5388-4c16-a30f-d105432553a4",
              "next": "/api/action/datastore_search?q=whatever&amp;offset=100&amp;resource_id=38625c3d-5388-4c16-a30f-d105432553a4"
          }
      }
  }
  </code></pre>
  
  <p>Data in servlet response <code>http://localhost:8080/getInstitutions?city=wahtever</code>:</p>
  
  <pre><code>"{\"help\": 
    \"https://inventory.data.gov/api/3/action/help_show?name\u003ddatastore_search\", 
    \"success\": true, 
    \"result\": {
      \"resource_id\": \"38625c3d-5388-4c16-a30f-d105432553a4\", 
      \"q\": \"wahtever\", 
      \"records\": [], 
      \"_links\": {
        \"start\": \"/api/action/datastore_search?q\u003dwahtever\u0026resource_id\u003d38625c3d-5388-4c16-a30f-d105432553a4\", 
        \"next\": \"/api/action/datastore_search?q\u003dwahtever\u0026offset\u003d100\u0026resource_id\u003d38625c3d-5388-4c16-a30f-d105432553a4\"
      }
    }
  }\n"
  </code></pre>