2014-05-02 41 views
0
{ 
    "message":"Task Title field is required.\nTask Description field is required.\nFrom Amount field is required.\nTo Amount field is required.\naddress field is required.\nzipcode field is required.\nlocationname field is required.\n", 
    "task_location":0, 

    "taskers":[{ 
    "worker_state":null, 
    "worker_app_approved":"1", 
    "password":"25d55ad283aa400af464c76d713c07ad", 
    "paypal_verified":"1", 
    "first_name":"Khushi", 
    "phone_no":null, 
    "is_pro_approve":"0", 
    "email_verification_code":"jyQlGbryzJae", 
    "worker_home_neighborhood":null, 
    "mobile_no":"", 
    "worker_work_neighborhood":null, 
    "worker_sms":"", 
    "worker_Internet":null, 
    "worker_background":null, 
    "worker_location_name":null, 
    "worker_tshirt":"", 
    "forget_password_request":"0", 
    "user_status":"1", 
    "worker_task_type":null, 
    "worker_birthdate":"0000-00-00", 
    "worker_level":"0", 
    "worker_first_name":"", 
    "twitter_screen_name":"", 
    "verify_email":"1", 
    "profile_is_private":"0", 
    "paypal_email":"[email protected]", 
    "email":"[email protected]", 
    "tw_id":"", 
    "worker_city":null, 
    "last_name":"amin", 
    "sign_up_ip":"1.22.81.187", 
    "worker_id":"4", 
    "worker_available_day":null, 
    "worker_skills":null, 
    "zip_code":"1234567", 
    "worker_date":"2014-03-31 07:48:53", 
    "worker_address":null, 
    "worker_mobile":"", 
    "worker_zipcode":null, 
    "user_id":"4", 
    "forget_password_code":null, 
    "fb_id":"100007768140568", 
    "sign_up_date":"2014-03-31 07:48:53", 
    "profile_name":"khushi-a", 
    "is_pro":"0", 
    "worker_status":"1", 
    "worker_transportation":null, 
    "worker_interview_approved":"0", 
    "worker_availability":null, 
    "worker_email":"", 
    "worker_available_time":null, 
    "worker_background_approved":"0", 
    "worker_devices":null, 
    "worker_hear_about":null, 
    "worker_last_name":"", 
    "full_name":"Khushi amin" 
    }], 

    "task_assign_worker":"0", 
    "user_location":0, 
    "task_id":"75", 
    "login":"false", 

    "tast_start_day":["Today","Tomorrow","Sunday, May 04","Monday, May 05","Tuesday, May 06", 
    "Wednesday, May 07","Thursday, May 08","Friday, May 09","Saturday, May 10","Sunday, May 11", 
    "Monday, May 12","Tuesday, May 13","Wednesday, May 14","Thursday, May 15","Friday, May 16"], 

    "tast_start_time":{ 
    "300":"5am", 
    "840":"2pm", 
    "1080":"6pm", 
    "240":"4am", 
    "1260":"9pm", 
    "660":"11am", 
    "960":"4pm", 
    "1320":"10pm", 
    "1380":"11pm", 
    "360":"6am", 
    "540":"9am", 
    "1020":"5pm", 
    "600":"10am", 
    "180":"3am", 
    "1200":"8pm", 
    "480":"8am", 
    "1140":"7pm", 
    "1440":"midnight", 
    "720":"noon", 
    "120":"2am", 
    "420":"7am", 
    "900":"3pm", 
    "60":"1am", 
    "780":"1pm"}, 

    "task_detail":{ 
    "task_end_day":"0", 
    "task_start_time":"0", 
    "city_timezone":"-5", 
    "extra_cost":"0.00", 
    "state_id":"152", 
    "task_accept":"0", 
    "category_status":"1", 
    "poster_agree":"0", 
    "comming_soon":"0", 
    "task_name":null, 
    "task_status":"3", 
    "task_assigned_date":"0000-00-00 00:00:00", 
    "task_activity_status":"0", 
    "category_name":"House Chore", 
    "more_details":null, 
    "category_image":"54880category_10.png", 
    "active":"1", 
    "category_url_name":"house-chore", 
    "task_online":"0", 
    "is_home":"1", 
    "task_close_date":"0000-00-00 00:00:00", 
    "city_name":"Acton", 
    "how_to_pay":"2", 
    "city_latitude":"43.633333", 
    "task_id":"75", 
    "task_price":"0.00", 
    "task_is_private":"0", 
    "city_longitude":"-80.033333", 
    "worker_agree":"0", 
    "city_id":"1764", 
    "task_url_name":null, 
    "user_id":"6", 
    "task_post_date":"2014-05-02 00:09:32", 
    "task_category_id":"1", 
    "task_end_date":"0000-00-00", 
    "country_id":"42", 
    "task_start_date":"0000-00-00", 
    "task_auto_assignment":"0", 
    "category_description":"House Chore", 
    "task_assing_worker":"0", 
    "task_worker_id":"0", 
    "task_city_id":"1764", 
    "task_attachment":"", 
    "task_complete_date":"0000-00-00 00:00:00", 
    "task_end_time":"0", 
    "task_description":null, 
    "category_parent_id":"0", 
    "category_average_price":"30", 
    "task_start_day":"0", 
    "task_ip":"210.89.56.198", 
    "task_cancel_date":"0000-00-00 00:00:00" 
    } 

} 

代码:价值凌晨5点不能被转换为JSONObject的

JSONObject abc = json.getJSONObject("tast_start_time"); 
Log.e("LOCATYION",json.getJSONArray("tast_start_day").toString()); 
Log.e("msg",abc.toString()); 
Log.e("msg",abc.getJSONObject("300").toString()); 

当我尝试登录jsonarray它完美的作品,但是当我试图获得的jsonobject 300它给了我一个例外。

回答

1

JSON对象abc包含键“300”处的字符串条目“5am”,而不是另一个JSON对象。所以它应该是:

Log.e("msg",abc.getString("300")); 
+0

感谢科多。我对日志还有一点怀疑。当我尝试显示非常长的日志进入日志猫这是休息,所以我想知道是它的限制显示日志或它被截断? – user3575871

1

属性“300”的值不是JSON对象,它是一个字符串。尝试类似于

Log.e("msg",abc.getString("300")); 
1

使用abc.getString("300");得到字符串值。

0

你试图得到jsonobject,但它的json字符串,这就是为什么你会得到错误。

Log.e("msg",abc.getJSONObject("300").toString()); 

替代品下面

Log.e("msg",abc.getString("300")); 

注: -

1. {} denote jsonobject 

2. [] denote jsonarray 

3. "value":"name" denote string 
相关问题