handle null/empty json string values

This commit is contained in:
REAndroid 2023-01-13 06:39:12 -05:00
parent 92a648612f
commit de90186007
6 changed files with 6 additions and 6 deletions

View File

@ -95,7 +95,7 @@ public class StringPoolBuilder {
}
if(jsonObject.has(ApkUtil.NAME_value_type)){
if(ValueType.STRING.name().equals(jsonObject.getString(ApkUtil.NAME_value_type))){
String data= jsonObject.getString(ApkUtil.NAME_data);
String data= jsonObject.optString(ApkUtil.NAME_data, "");
addTableString(data);
}
return;

View File

@ -435,7 +435,7 @@ import java.util.Set;
}
ValueType valueType=ValueType.fromName(json.getString(NAME_value_type));
if(valueType==ValueType.STRING){
setValueAsString(json.getString(NAME_data));
setValueAsString(json.optString(NAME_data, ""));
}else if(valueType==ValueType.INT_BOOLEAN){
setValueAsBoolean(json.getBoolean(NAME_data));
}else {

View File

@ -288,7 +288,7 @@ package com.reandroid.lib.arsc.chunk.xml;
results.add(attr.getString(ResXmlAttribute.NAME_name));
ValueType valueType=ValueType.fromName(attr.getString(ResXmlAttribute.NAME_value_type));
if(valueType==ValueType.STRING){
results.add(attr.getString(ResXmlAttribute.NAME_data));
results.add(attr.optString(ResXmlAttribute.NAME_data));
}
}
}

View File

@ -761,7 +761,7 @@ import java.util.*;
start.setComment(json.optString(NAME_comment, null));
String text= json.optString(NAME_text, null);
if(text!=null){
setResXmlText(text);
addResXmlText(text);
}
String uri = json.optString(NAME_namespace_uri, null);
if(uri!=null){

View File

@ -204,7 +204,7 @@ public class ResValueBagItem extends BaseResValueItem{
setType(valueType);
setId(json.getInt(NAME_id));
if(valueType==ValueType.STRING){
setValueAsString(json.getString(NAME_data));
setValueAsString(json.optString(NAME_data, ""));
}else if(valueType==ValueType.INT_BOOLEAN){
setValueAsBoolean(json.getBoolean(NAME_data));
}else {

View File

@ -127,7 +127,7 @@ public class ResValueInt extends BaseResValueItem {
public void fromJson(JSONObject json) {
ValueType valueType=ValueType.fromName(json.getString(NAME_value_type));
if(valueType==ValueType.STRING){
setValueAsString(json.getString(NAME_data));
setValueAsString(json.optString(NAME_data, ""));
}else if(valueType==ValueType.INT_BOOLEAN){
setValueAsBoolean(json.getBoolean(NAME_data));
}else {