title: conversion of java string to json object
body: <p>I have json object named 'jo' in the below code.I convert this json object to java string to return this json object as response.Then how i convert this string back to json object in the required format.Please help me.</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@page import="java.sql.*"%&gt;
  &lt;%@page import="java.util.*,java.util.ArrayList"%&gt;
  &lt;%@page import="net.sf.json.JSONObject"%&gt;
  &lt;%@page import="net.sf.json.JSONArray"%&gt;
  &lt;%
      JSONArray cellarray = new JSONArray();
      JSONObject cellobj = null; //new JSONObject();
      JSONObject jo=new JSONObject();
      String country=request.getParameter("count");  
      try{
          Class.forName("com.mysql.jdbc.Driver").newInstance();  
          Connection con = DriverManager.getConnection("jdbc:mysql://localhost:
          3306/test","root","root");  
          Statement stmt = con.createStatement();  
          ResultSet rs = stmt.executeQuery("Select * from state 
          where countryid='"+country+"'");  
              while(rs.next()){
                  cellobj = new JSONObject();
                  cellobj.put("id", rs.getString(1));
                  cellobj.put("name", rs.getString(3));
                  cellarray.add(cellobj);
              }  
              jo.put("arrayName",cellarray);
              response.setContentType("application/json");
              response.setCharacterEncoding("UTF-8");
              response.getWriter().write(jo.toString());
          }
      catch(Exception e){
          System.out.println(e);
      }
  %&gt;
  </code></pre>