以前用JSonObject解析的时候需要导入一大堆的jar包,所以很不方便。其实android自带JSonObject解析。特意把使用方法记录下来
/** *上传结果*/privatevoidupLoadResult(Messagemsg){//{"errorDesc":"","code":"000"}Stringresult=(String)msg.obj;JSONTokenertoker=newJSONTokener(result)try{JSONObjectjsonObject=(JSONObject)toker.nextValue()Stringcode=jsonObject.getString("code")StringerrorDesc=jsonObject.getString("errorDesc"if("000".equals(code)){UpLoad.this.finish()}elseToast.makeText(UpLoad.this,"上传失败"+errorDesc,255)">LENGTH_SHORT).show()catch(JSONExceptione){e.printStackTrace()}
导入的包
importorg.json.JSONExceptionorg.json.JSONObjectorg.json.JSONTokener; (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|