Open PurnAnrup opened 3 hours ago
optString
MethodTo address the issue where optString
does not return the expected default value when the key is absent or explicitly set to null
, I propose the following modification:
public String optString(String key, String defaultValue) {
Object o = opt(key);
return (o == null || ((Null) o).isExplicitNull()) ? defaultValue : o.toString();
}
o
is null
, and we want to return the defaultValue
.null
, o
will be an instance of Null
, and isExplicitNull()
will return true
, prompting the method to return the defaultValue
.
Sure! Here’s the issue description formatted in Markdown:
optString
method with the key and a default value.Expected Behavior
The expected output should be:
Actual Behavior
The actual output is:
Additional Information