Json解析值get与opt的区别
来源:互联网 发布:里约奥运会直播软件 编辑:程序博客网 时间:2024/05/22 12:26
//optJSONObject源码解析:
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}. Returns null otherwise.
*/
public JSONObject optJSONObject(String name) {
Object object = opt(name);
return object instanceof JSONObject ? (JSONObject) object : null;
}
//当返回值不是JSONObject对象时,返回值为null,不抛出异常;
//getJSONObject源码解析:
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}.
* @throws JSONException if the mapping doesn't exist or is not a {@code
* JSONObject}.
*/
public JSONObject getJSONObject(String name) throws JSONException {
Object object = get(name);
if (object instanceof JSONObject) {
return (JSONObject) object;
} else {
throw JSON.typeMismatch(name, object, "JSONObject");
}
}
//当返回值不是JSONObject对象时,抛出异常;
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}. Returns null otherwise.
*/
public JSONObject optJSONObject(String name) {
Object object = opt(name);
return object instanceof JSONObject ? (JSONObject) object : null;
}
//当返回值不是JSONObject对象时,返回值为null,不抛出异常;
//getJSONObject源码解析:
/**
* Returns the value mapped by {@code name} if it exists and is a {@code
* JSONObject}.
* @throws JSONException if the mapping doesn't exist or is not a {@code
* JSONObject}.
*/
public JSONObject getJSONObject(String name) throws JSONException {
Object object = get(name);
if (object instanceof JSONObject) {
return (JSONObject) object;
} else {
throw JSON.typeMismatch(name, object, "JSONObject");
}
}
//当返回值不是JSONObject对象时,抛出异常;
0 0
- Json解析值get与opt的区别
- json解析中 opt和get的区别
- JSON中get()和opt()的区别
- JSON中get()和opt()的区别
- JSON中的get和opt方法的区别
- JSON中的get和opt方法的区别
- net.sf.json.JSONObject optDouble 与getDouble opt** 与 get**
- Json与XML解析的区别比较
- Json解析时,一系列opt***方法
- liunx下/opt目录与/usr目录的区别
- javascript中JSON.parse()与eval()解析json的区别
- JSON解析与 XML解析的区别比较
- jQuery源码解析---get与eq的区别
- get 与 post的区别?application json 与form表单的区别?
- 小言C#与java对json的解析区别
- JSON解析之optJSONObject与getJSONObject的区别
- JSONObject与JSONArray的区别 解析json数据
- httpClient(Get)解析JSON
- mysql命令行中文显示乱码和输出表格不能对齐解决办法
- PHP简单语句
- Openstack-nova
- mysql远程防火墙3306端口
- 模拟实现智能指针
- Json解析值get与opt的区别
- android中使用wifi来adb
- iOS页面通过KVO传值
- react native Command /bin/sh failed with exit code 1( at process._tickCallback (node.js:336:13))
- 通过web连接页面打开app在 appstore中的详情
- 深谈读研如何提高技术
- 学习历程《C语言陷阱和缺陷》
- 使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境
- 一款好用的备忘录制作实现