1

org.json.me を使用して BlackBerry で JSON の解析に取り組んでいますが、結果を解析できません。シミュレータ コンソールは言う: No Stack Trace

これは、restclient から JSON 文字列を受け取った後に JSON を解析するコードです。

    try {
        JSONObject outer=new JSONObject(data);     
        JSONArray ja = outer.getJSONArray("status");
        JSONArray arr=ja.getJSONArray(0);               
        System.out.println(arr);
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

そして、サーバーから JSON を取得するコードは次のとおりです。

public PromoThread(final String url, final ResponseCallback callback){
    Thread t = new Thread(new Runnable(){
        public void run() {
            waitScreen = new WaitPopupScreen();

            System.out.println("Log >> Promo thread run...");
            synchronized (UiApplication.getEventLock()){
                UiApplication.getUiApplication().pushScreen(waitScreen);
            }
            //network call
            try {
                conn = (HttpConnection) new ConnectionFactory().getConnection(url).getConnection();
                conn.setRequestMethod(HttpConnection.GET);
                conn.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Confirguration/CLDC-1.0");

                if (conn.getResponseCode() == HttpConnection.HTTP_OK) {
                    in = conn.openInputStream();
                    // parser.parse(in, handler);
                    //buff.append(IOUtilities.streamToBytes(in));
                    //result = buff.toString();
                    results = new String(IOUtilities.streamToBytes(in));
                    //System.out.println("Log >> Result: " + results);
                    UiApplication.getUiApplication().invokeLater(
                            new Runnable() {
                                public void run() {
                                    //UiApplication.getUiApplication().popScreen(waitScreen);
                                    callback.callback(results, waitScreen);
                                }
                    }); 
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                    conn.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    });

    //start thread
    t.start(); 
}

ご協力いただきありがとうございます

4

0 に答える 0