以前用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;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。