好日子,如何獲取這個Json響應並將其插入到Android SQLite中。 希望你能指導我如何獲取這個JSON對象一個JSON數組內對象更新:如何插入一個Json數組到JSON數組到SQLite
{
"error": false,
"sl_summ": [
{
"sl_desc": "PA : Savings Account",
"tr_date": "2015-08-17",
"actual_balance": "483.67",
"available_balance": "483.67"
},
{
"sl_desc": "PA : Savings - Cash Bond",
"tr_date": "2015-08-28",
"actual_balance": "10129.43",
"available_balance": "10129.43"
}
]
}
這是我整個JSON響應裏面。第一個Json對象(用戶)成功解析並插入數據庫,但第二個Json響應(sl_summ)解析失敗並未插入。這就是我的問題。
{
"error": false,
"user": {
"br_code": 12,
"mem_id": 13,
"username": "novalyn",
"email": "[email protected]",
"created_at": "2016-07-22 09:05:21"
}
}
{
"error": false,
"sl_summ":
[
{
"sl_desc": "PA : Savings Account",
"tr_date": "2015-08-17",
"actual_balance": "483.67",
"available_balance": "483.67"
},
{
"sl_desc": "PA : Savings - Cash Bond",
"tr_date": "2015-08-28",
"actual_balance": "10129.43",
"available_balance": "10129.43"
}
]
}
這是logcat的消息
D/RegisterActivity: Login Response: {"error":false,"user":{"br_code":12,"mem_id":13,"username":"novalyn","email":"[email protected]","created_at":"2016-07-22 09:05:21"}}{"error":false,"sl_summ":[{"sl_desc":"PA : Savings Account","tr_date":"2015-08-17","actual_balance":"483.67","available_balance":"483.67"},{"sl_desc":"PA : Savings - Cash Bond","tr_date":"2015-08-28","actual_balance":"10129.43","available_balance":"10129.43"}]}
07-05 16:19:15.068 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/[email protected][LoginActivity]: dispatchDetachedFromWindow
07-05 16:19:15.083 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/InputTransport: Input channel destroyed: fd=76
07-05 16:19:15.084 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/RegisterActivity: Checking JSON Object{"error":false,"user":{"br_code":12,"mem_id":13,"username":"novalyn","email":"[email protected]","created_at":"2016-07-22 09:05:21"}}
07-05 16:19:15.085 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/TEST: -error attribute : false
07-05 16:19:15.094 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SessionManager: User login session modified!
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -user object : {"br_code":12,"mem_id":13,"username":"novalyn","email":"[email protected]","created_at":"2016-07-22 09:05:21"}
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -br_code : 12
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -mem_id : 13
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -username : novalyn
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -email : [email protected]
07-05 16:19:15.095 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/USER: -created at : 2016-07-22 09:05:21
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: New member was inserted into table members: 13
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: BR CODE: 12
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: Member ID: 13
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: Username: novalyn
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: Email: [email protected]
07-05 16:19:15.117 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/SQLiteHandler: Created at: 2016-07-22 09:05:21
07-05 16:19:15.118 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/sl_summ: JSON String : {"error":false,"user":{"br_code":12,"mem_id":13,"username":"novalyn","email":"[email protected]","created_at":"2016-07-22 09:05:21"}}
07-05 16:19:15.118 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/sl_summ: -error attribute : false
07-05 16:19:15.119 20514-20514/ph.coredev.johnjessbayutas.gsacmobileportal D/TEST: org.json.JSONException: No value for sl_summ
我注意到,只有第一個響應返回
D/sl_summ: JSON String : {"error":false,"user":{"br_code":12,"mem_id":13,"username":"novalyn","email":"[email protected]","created_at":"2016-07-22 09:05:21"}}
D/sl_summ: -error attribute : false
D/TEST: org.json.JSONException: No value for sl_summ
你好,你的問題我也不清楚。你想知道如何去解析一個JSON b)在SQLite中保存JSON c)能夠從SQLite –
a,b和c sir @ RuchiraRandana返回對象。我想解析JSON保存到SQLite和檢索對象 – Novice