title: Getting Error in JSON Parsing while sending an JSON object with parameter
body: <p>While parsing the data faced problem below.</p>
  
  <pre><code>"12-13 14:18:41.769: E/JSON Parser(17409): Error parsing data org.json.JSONException: Value ï»¿&lt;?xml of type java.lang.String cannot be converted to JSONObject" 
  </code></pre>
  
  <p>I want to send an Request object like this and also want to print the request object while sending:-</p>
  
  <pre><code>"objTimesheet" : 
  
  {
  
  "ClassicLevel" : "1",
  "CurrentLevel" : "2",
  "UpdatedDate" : "5-12-13",
  "Name":"Ankit",
  "UpdatedTime": "20",
  "Message":""
  
  }
  </code></pre>
  
  <p>This is my JSON parser class:-</p>
  
  <pre><code>public class JSONParser {
  
      static InputStream is = null;
      static JSONObject jObj = null;
      static String json = "";
  
      // constructor
      public JSONParser() {
  
      }
  
      // function get json from url
      // by making HTTP POST or GET mehtod
      public JSONObject makeHttpRequest(String url, String method,
              List&lt;NameValuePair&gt; params) {
  
          // Making HTTP request
          try {
  
              // check for request method
              if (method == "POST") {
                  // request method is POST
                  // defaultHttpClient
                  DefaultHttpClient httpClient = new DefaultHttpClient();
                  HttpPost httpPost = new HttpPost(url);
                  httpPost.setEntity(new UrlEncodedFormEntity(params));
                  HttpResponse httpResponse = httpClient.execute(httpPost);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
  
              } else if (method == "GET") {
                  // request method is GET
                  DefaultHttpClient httpClient = new DefaultHttpClient();
  
                  String paramString = URLEncodedUtils.format(params, "utf-8");
                  url += "?" + paramString;
  
                  HttpGet httpGet = new HttpGet(url);
                  HttpResponse httpResponse = httpClient.execute(httpGet);
                  HttpEntity httpEntity = httpResponse.getEntity();
                  is = httpEntity.getContent();
              }
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
              BufferedReader reader = new BufferedReader(new InputStreamReader(
                      is, "iso-8859-1"), 8);
          /*  BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"),8);*/
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              json = sb.toString();
          } catch (Exception e) {
              Log.e("Buffer Error", "Error converting result " + e.toString());
          }
  
          // try parse the string to a JSON object
          try {
              jObj = new JSONObject(json);
          } catch (JSONException e) {
              Log.e("JSON Parser", "Error parsing data " + e.toString());
          }
  
          // return JSON String
          return jObj;
  
  
      }
  }
  </code></pre>
  
  <p>And In my activity I execute this following:-</p>
  
  <pre><code>List&lt;NameValuePair&gt; params1 = new ArrayList&lt;NameValuePair&gt;();
  
          params1.add(new BasicNameValuePair(CLASSICLevel, "1"));
          params1.add(new BasicNameValuePair(CURRENTLevel, "2"));
          params1.add(new BasicNameValuePair(UPDATEDate, "345"));
          params1.add(new BasicNameValuePair(NAME, "Nil"));
          params1.add(new BasicNameValuePair(UPDATETIME, "10"));
  
          json = jparser.makeHttpRequest(url_login, "POST", params1);
  </code></pre>
  
  <p>Can any one give me proper solution for this to send the above request and get the response..Thanks in advance</p>