Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ANDROID中使用json解析大约3MB大小的数据?_Android_Json - Fatal编程技术网

在ANDROID中使用json解析大约3MB大小的数据?

在ANDROID中使用json解析大约3MB大小的数据?,android,json,Android,Json,我必须通过JSon通过大小约为3MB的HTTP请求解析数据,但我使用的解析器无法做到这一点。以下是JSon解析器: public static JSONObject getJSONfromURL(String url){ InputStream is = null; String result = ""; JSONObject jArray = null; //http post try{ HttpClient httpclient =

我必须通过JSon通过大小约为3MB的HTTP请求解析数据,但我使用的解析器无法做到这一点。以下是JSon解析器:

public static JSONObject getJSONfromURL(String url){

    InputStream is = null;
    String result = "";
    JSONObject jArray = null;

    //http post
    try{
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();

    }catch(Exception e){
          //  Log.e("log_tag", "Error in http connection "+e.toString());
    }

    //convert response to string
    try{
        BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),102400);

        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
        }
        is.close();
        result=sb.toString();

    }catch(Exception e){
           // Log.e("log_tag", "Error converting result "+e.toString());
    }

    try{

        jArray = new JSONObject(result);            
    }catch(JSONException e){
           // Log.e("log_tag", "Error parsing data "+e.toString());
    }
    return jArray;
}

任何帮助都将不胜感激。谢谢

您正在解析内存中的整个3MB字符串。它会导致内存不足异常。分析流中的大数据:

  • 自API级别11起
  • 库或用于大数据

请指定“无法执行”。异常、警告、日志?请您提及要分析的数据。否则,将创建获取该数据的链接