jsonException没有startDate的值

时间:2014-10-26 10:52:21

标签: android json

这是我的json数组

dList = [{projectName=Proj 2, startDate=2014-04-20, userId=mahi}]

这是我的代码

@Override
protected Void doInBackground(Void... params) {
     HttpClient client =new DefaultHttpClient();
     // String SERVICE_URL2= String.format(
         "http://track365.in/app/userexpancedetails?user_Id="+user_id+"");
     String SERVICE_URL2= String.format(
         "http://track365.in/app/userexpancedetails?user_Id="+user_id+"");
     System.out.println("dddddddddd"+SERVICE_URL2);

      HttpGet getrequest= new HttpGet(SERVICE_URL2);

      try {
                HttpResponse response=client.execute(getrequest);
                InputStream jsdata= response.getEntity().getContent();
                BufferedReader reader= new BufferedReader(
                    new InputStreamReader(jsdata));
                StringBuilder builder = new StringBuilder();
                String line;
                while((line=reader.readLine())!=null)
                {
                    builder.append(line);
                }
                String Jsondata=builder.toString();

                System.out.println("Jason called");

                JSONArray item1=new JSONArray(Jsondata);

                int temp1=item1.length();
                for(int i = 0; i < item1.length(); i++)
                {
                    if(i<temp1)
                    {
                        JSONObject c = item1.getJSONObject(i);

                        strat_date = c.getString(sdate);
                        proj_name = c.getString(project_name);
                        String user_id=c.getString(userid);

                    }
                    runOnUiThread(new Runnable()
                    {
                        public void run() 
                        {

                            statdate.setText(strat_date.toString());
                            projname.setText(proj_name.toString());
                        }                             
                    });                     
                }                   
            }          
            catch (Exception e) 
            {
                e.printStackTrace();
            } 
            return null;
        }

    @Override
    protected void onPostExecute(Void result) 
    {
         pDlg.dismiss();
         System.out.println("sync task ended");
    }

    // Establish connection and socket (data retrieval) timeouts
    @SuppressWarnings("unused")
    private HttpParams getHttpParams()
    {
        HttpParams htpp = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(htpp, CONN_TIMEOUT);
        HttpConnectionParams.setSoTimeout(htpp, SOCKET_TIMEOUT);

        return htpp;
    }

    protected void onProgressUpdate() 
    {
          runOnUiThread(null);
    }
}

0 个答案:

没有答案