Java – JSON parsing problem

Invalid Sign

When I put it into the JSON object, it brings me an error. The error is: 08-31 14:40:52.281: warn / system. Err (416): org.json.jsonexception: the value of type java.lang.string cannot be converted to jsonobject

public static String getmyproductquestiondetails(String userid,
        String campaignid) {// https://www.buzzador.com/apps/present_software/webservice/index.PHP?op=EducationResult&userid=1&questionid=1,2,3&answergivenbyuser=1,1,0
    String data = null;
    try {

        URL url = new URL(
                "http://dignizant.com/buzz/webservice/index.PHP?op=getProductQuestion&userid="
                        + userid + "&campaign_id=" + campaignid);
        if (url.getProtocol().toLowerCase().equals("https")) {
            trustAllHosts();
            HttpsURLConnection https = (HttpsURLConnection) url
                    .openConnection();
            https.setHostnameVerifier(DO_NOT_VERIFY);
            http = https;
        } else {
            http = (HttpURLConnection) url.openConnection();
        }
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Utils utils = new Utils();

    try {
        data = utils.convertStreamToString(http.getInputStream());
        System.out.println("getproduct details response :: " + data);

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

        data = e.toString();

    }
    return data;
}







try {


        JSONObject jo = new JSONObject(response);

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }

resolvent:

  char[] utf8 = null;
            StringBuilder properString = new StringBuilder("");

            utf8 = Response.tocharArray();

            for (int i = 0; i < utf8.length; i++) {
                if ((int) utf8[i] < 65000) {
                    properString.append(utf8[i]);
                }
            }
  System.out.println("Response of Login::"
                        + properString.toString());

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>