Shi*_*nsu 3 java android json exception-handling
我通过以下步骤在Android中进行JSON解析:
现在问题是有时XML响应具有空字符串或Null标记.
例如:
<data>
<name>Martin Clark</name>
<city>London</city>
<country>XYZ</country> or <country /> <!-- Sometimes it will blank string like this if country is not available -->
<age>27</age>
</data>
Run Code Online (Sandbox Code Playgroud)
解析风格:
jsonObject.getString("country"); // It is working perfect when xml is this : <country>XYZ<country/>
jsonObject.getString("country"); // It is giving Exception key is not found when xml is this : <country />
Run Code Online (Sandbox Code Playgroud)
我不明白为什么解析器没有给我空白XML对象的BLANK字符串.
通过深层次调试,我发现XML到JSON转换器不会产生对应于空白xml对象的对象.
请帮我.
| 归档时间: |
|
| 查看次数: |
139 次 |
| 最近记录: |