加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

系统自带JSonObject解析

发布时间:2020-12-16 19:00:52 所属栏目:百科 来源:网络整理
导读:以前用JSonObject 解析的时候需要导入一大堆的 jar 包,所以很不方便。其实 android 自带 JSonObject 解析。特意把使用方法记录下来 /** *上传结果 */ privatevoid upLoadResult (Messagemsg){ //{"errorDesc":"","code":"000"} Stringresult=(String)msg. o

以前用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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读