Hi,
We are using JSON-lib 0.9 to convert our beans to JSON format before
sending the response. Our bean uses many BigDecimal fields. We tried the
following:
JSONObject.fromBean(new BigDecimal(10));
This throws the following exception:
Caused by: java.lang.NoSuchMethodException: Property 'scale' has no
getter method
at
org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(Propert
yUtilsBean.java:1127)
at
org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Propert
yUtilsBean.java:686)
at
org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtils
Bean.java:715)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav
a:290)
at net.sf.json.JSONObject.fromBean(JSONObject.java:161)
The apache commons searches for getter setter methods for each member
variable - which is not present for this class.
Even the fromObject method throws a similar exception. The JSON utils
function isNumber does not identify BigDecimal as a number. This causes
problems here.
We have too many BigDecimal fields in our bean and so would rather not
move to any other data type. Can you help us here please? We are
completely stuck.
Regards
~Rashmi
|