Some possible solutions to resolve it.
Use a pseudo getter
public String getBigFieldString() {
return bigField != null ? bigField.toPlainString : null;
}
and plugin will serialize it as bigFieldString:"12345678901234567890.123456789123456789"
. You can also use field's getter to do this.
Change JSON Plugin Code
Copy org.apache.struts2.json.JSONWriter
class from JSON Plugin to your project code. and update process
method as below. (Be careful while doing this.)
package org.apache.struts2.json;
...
class JSONWriter {
...
private void process(Object object, Method method) throws JSONException {
this.stack.push(object);
if (object instanceof Class) {
this.string(object);
} else if (object instanceof Boolean) {
this.bool((Boolean) object);
}
// Begin: Handling of Big Decimal, Keep this code above Handling of Number
else if (object instanceof BigDecimal) {
this.string(((BigDecimal)object).toPlainString());
}
// End: Handling of Big Decimal
else if (object instanceof Number) {
this.add(object);
} else if (object instanceof String) {
this.string(object);
} else if (object instanceof Character) {
this.string(object);
} else if (object instanceof Map) {
this.map((Map) object, method);
} else if (object.getClass().isArray()) {
this.array(object, method);
} else if (object instanceof Iterable) {
this.array(((Iterable) object).iterator(), method);
} else if (object instanceof Date) {
this.date((Date) object, method);
} else if (object instanceof Calendar) {
this.date(((Calendar) object).getTime(), method);
} else if (object instanceof Locale) {
this.string(object);
} else if (object instanceof Enum) {
this.enumeration((Enum) object);
} else {
this.bean(object);
}
this.stack.pop();
}
...
}