我是android編程的新手。我試圖通過解析它來在我的android應用程序中烘烤用戶id的值,但錯誤表示沒有用戶值。如何從android中的json數據獲取輸入?我附上我的logcat錯誤below.Can任何人請幫助我?在先進的感謝如何解析json分支值
"status": "SUCCESS",
"msg": "Login Successful",
"data": {
"user": {
"id": "6",
"first_name": "e",
"last_name": "ff",
"address": "dr",
"mobile": "55",
"email": "[email protected]",
"password": "4124bc0a9335c27f086f24ba207a4912",
"pwd_reset_key": "",
"name_on_card": "",
"card_number": "",
"expiry_date": "",
"cvv": "",
"tdatetime": "2014-07-11 02:55:08"
}
}
logcat的錯誤:
09-05 03:36:00.567: D/dalvikvm(2227): GC_FOR_ALLOC freed 379K, 8% free 5765K/6220K, paused 76ms, total 82ms
09-05 03:36:02.077: W/Response(2227): {"GET":[],"POST":{"action":"login","app_secret":"jkhljkUILJGJkljhkjUGLG87796587687HGKJhghkjKUYGKJHjhgjUYGKUY7865876hgKUYGK","email":"[email protected]","password":"aa"},"status":"SUCCESS","msg":"Login Successful","data":{"user":{"id":"6","first_name":"e","last_name":"ff","address":"dr","mobile":"55","email":"[email protected]","password":"4124bc0a9335c27f086f24ba207a4912","pwd_reset_key":"","name_on_card":"","card_number":"","expiry_date":"","cvv":"","tdatetime":"2014-07-11 02:55:08"}}}
09-05 03:36:02.107: W/System.err(2227): org.json.JSONException: No value for user
09-05 03:36:02.117: W/System.err(2227): at org.json.JSONObject.get(JSONObject.java:355)
09-05 03:36:02.117: W/System.err(2227): at org.json.JSONObject.getString(JSONObject.java:515)
09-05 03:36:02.147: W/System.err(2227): at example.atlcitylimo.Main.postLoginData(Main.java:116)
09-05 03:36:02.147: W/System.err(2227): at example.atlcitylimo.Main.onClick(Main.java:181)
09-05 03:36:02.147: W/System.err(2227): at android.view.View.performClick(View.java:4438)
09-05 03:36:02.147: W/System.err(2227): at android.view.View$PerformClick.run(View.java:18422)
09-05 03:36:02.147: W/System.err(2227): at android.os.Handler.handleCallback(Handler.java:733)
09-05 03:36:02.147: W/System.err(2227): at android.os.Handler.dispatchMessage(Handler.java:95)
09-05 03:36:02.147: W/System.err(2227): at android.os.Looper.loop(Looper.java:136)
09-05 03:36:02.157: W/System.err(2227): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-05 03:36:02.157: W/System.err(2227): at java.lang.reflect.Method.invokeNative(Native Method)
09-05 03:36:02.157: W/System.err(2227): at java.lang.reflect.Method.invoke(Method.java:515)
09-05 03:36:02.157: W/System.err(2227): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-05 03:36:02.157: W/System.err(2227): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-05 03:36:02.157: W/System.err(2227): at dalvik.system.NativeStart.main(Native Method)
感謝的人,它的工作.... – 2014-09-05 07:59:07
@ mystic_knight,你是受歡迎的,但不要忘了接受的答案 – user3376296 2014-09-05 20:11:07