0
    try {

                    String ret = jsnparse.getUrlString(params[0]);
                    ret = ret.trim();           
                    JSONObject jsonObj = new JSONObject(ret);

                    JSONArray products = jsonObj.getJSONArray(TAG_JsonArray);
                    JSONObject tmp;
                    for(int i=0; i<products.length(); i++){
                        tmp = products.getJSONObject(i);
                        FacultyMemberClass _product = new FacultyMemberClass(
                                tmp.getString(TAG_id),
                                1,
                                tmp.getString(TAG_Name)+" "+ tmp.getString(TAG_surName),
                                "(" +tmp.getString(TAG_RankPosition)+")" + tmp.getString(TAG_RankTitle), 
                                tmp.getString(TAG_Research), 
                                tmp.getString(TAG_Email),
                                tmp.getString(TAG_Office), 
                                tmp.getString(TAG_Phone),
                                tmp.getString(TAG_Photo)
                                );

                        productList.add(_product);
                    }
                } catch (SocketTimeoutException e) {
                    e.printStackTrace();
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return productList;

            }

i am using these codes to parse my json code, it is work for http://www.gorkemkaradogan.com/Personnel.txt
but it is not runinng http://www.gorkemkaradogan.com/Personnel.aspx , when i give this url
my jsonparse class is ; `package com.example.cmpeemu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpGet;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.http.AndroidHttpClient;


public class JSONParser {
     public static final int connectTimeout = 10*1000; // 10 seconds..


    // constructor
    public JSONParser() {

    }


    public static String getUrlString(String url)
                      throws MalformedURLException, SocketTimeoutException, IOException{
        InputStream in = null;
        BufferedReader reader = null;
        URLConnection feedUrl;
        String ret = "";
        feedUrl = new URL(url).openConnection();

        feedUrl.setConnectTimeout(connectTimeout);
        feedUrl.setReadTimeout (connectTimeout);
        in = feedUrl.getInputStream();
        reader = new BufferedReader(new InputStreamReader(in,"ISO-8859-9"));
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        ret = sb.toString();
        in.close();
        return ret;
     }



    public Bitmap downloadBitmap(String url) throws MalformedURLException, IOException {
       final AndroidHttpClient client = AndroidHttpClient.newInstance("Android");
       final HttpGet getRequest = new HttpGet(url);

       try {
          HttpResponse response = client.execute(getRequest);
          final int statusCode = response.getStatusLine().getStatusCode();
          if (statusCode != HttpStatus.SC_OK) {
             return null;
          }

          final HttpEntity entity = response.getEntity();
          if (entity != null) {
              InputStream inputStream = null;
              try {
                  inputStream = entity.getContent();
                  final Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
                  return bitmap;
              } finally {
                  if (inputStream != null) {
                     inputStream.close();
                  }
                  entity.consumeContent();
              }
          }
       } catch (MalformedURLException e) {
          getRequest.abort();
          e.printStackTrace();
       } catch (IOException e) {
          getRequest.abort();
          e.printStackTrace();
       } finally {
          if (client != null) {
              client.close();
          }
       }
       return null;
     }
}

为什么它不适用于我的 aspx 文件。另一方面,在我的 json 代码中,有用于 exapmle 讲师_en 和讲师_tr 的数组,在顶部有讲师_en,但是当 TAG_JsonArray 是讲师_tr 时它没有运行,它必须在顶部代码,我不知道为什么会这样。

4

1 回答 1

0

因为你的aspx不是json,它是html:

查看源代码:http ://www.gorkemkaradogan.com/Personnel.aspx

截屏

于 2013-03-22T22:26:07.457 回答