您好,欢迎访问一九零五行业门户网

php-JSONException错误:android客户端

phpandroid
java.文件,错误:int success = json.getint(tag_success);
protected string doinbackground(string... args) { // building parameters list params = new arraylist(); // getting json string from url jsonobject json = jparser.makehttprequest(url_all_products, get, params); // check your log cat for json reponse log.d(all products: , json.tostring()); try { // checking for success tag **int success = json.getint(tag_success);** if (success == 1) { // products found // getting array of products products = json.getjsonarray(tag_products); log.d(level1: , @@@@@@@@@@@@@@@@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$); // looping through all products for (int i = 0; i map = new hashmap(); // adding each child node to hashmap key => value map.put(tag_pid, id); map.put(tag_name, name); // adding hashlist to arraylist productslist.add(map); } } else { // no products found // launch add new product activity log.d(level3: , jldksffffffffffffffffffffffffffffffffffffff); intent i = new intent(getapplicationcontext(), newproductactivity.class); // closing all previous activities i.addflags(intent.flag_activity_clear_top); startactivity(i); } } catch (jsonexception e) { e.printstacktrace(); } return null;}
服务器的jsonarray如下,我已经通过jsonlint.con验证过了
{tbl_user: { 0: { id: 195, email: aru@yahoo.com, password: 202cb962ac59075b964b07152d234b70, fname: aru, lname: sharma }, 1: { id: 196, email: manu@yahoo.com, password: 202cb962ac59075b964b07152d234b70, fname: manu, lname: sharma }, 2: { id: 197, email: rishi@yahoo.com, password: 202cb962ac59075b964b07152d234b70, fname: rishi, lname: sharma }, success: 1}}
然后php代码如下:
function getusers() {$sql = select * from tbl_user order by fname;try { $db = getconnection(); $stmt = $db->query($sql); $users = $stmt->fetchall(pdo::fetch_obj); $users[success] = 1; $db = null; echo '{tbl_user: ' . json_encode($users) . '}';} catch(pdoexception $e) { echo '{error:{text:'. $e->getmessage() .'}}'; }}
请帮我解决一下,谢谢。
其它类似信息

推荐信息