android - 仅在启用 proguard 时 JSONArray 不是字符串异常

标签 android json exception proguard obfuscation

JSONArray.getString(1);其中 ["n​​ame",null] 是 json 数组,抛出 JSONArray[1] not a string仅在启用 proguard 时异常(exception)。

我在我的 proguard 规则中遗漏了什么吗?

最佳答案

您是否尝试过这些方法:

/**
 * Returns the value at {@code index} if it exists, coercing it if
 * necessary. Returns the empty string if no such value exists.
 */
public String optString(int index)

或者
/**
 * Returns the value at {@code index} if it exists, coercing it if
 * necessary. Returns {@code fallback} if no such value exists.
 */
public String optString(int index, String fallback)

好像不返回 null对于字符串

关于android - 仅在启用 proguard 时 JSONArray 不是字符串异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39593619/

相关文章:

java - 显示键盘时如何调整布局大小

android - ActionBar ShowActions & v7 兼容

android - 找不到 BiometricPrompt 的支持库

c++ - 当我抛出异常时会发生什么?

c# - BitmapFrame.Create 异常(WPF 框架中的错误?)

c# - 如何获取导致异常的方法的名称

android - RxJava2 延迟不起作用

json - 如何将 F# Union 类型与 Servicestack JSON 序列化结合使用?

javascript - 我如何重构这个 JSON 以使其更易于访问

javascript - localStorage中的JS数据仅保存在一个键,值对中