[
https://issues.apache.org/jira/browse/PIVOT-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020990#comment-13020990
]
Sandro Martini commented on PIVOT-704:
--------------------------------------
Hi Greg,
yes, I've just find the right solution (I hope :-) ), in the way you suggested.
But without calling the if instanceof (otherwise during deserialization is will
not be able to find the right parameter type for the setter). Shortly this is
an extract of the fix:
} else if (type == BigInteger.class) {
coercedValue = new BigInteger(value.toString());
} else if (type == BigDecimal.class) {
coercedValue = new BigDecimal(value.toString());
// TODO: move this as first choice ... // currently this is here just as a
reminder
} else if (type == String.class) {
coercedValue = value.toString();
And last, given the (usually high) frequency of String attributes, I'm thinking
to move the if (instanceof String) block as first choice, to have a little
speedup, ok ?
Thank you for the moment.
Today/tomorrow I'll commit this fix and related changes to the test case (and
resolve the issue), tell me if something is still not working (and/or reopen
the ticket).
Bye,
Sandro
> JSONSerializer can't deserialize to BigDecimal
> ----------------------------------------------
>
> Key: PIVOT-704
> URL: https://issues.apache.org/jira/browse/PIVOT-704
> Project: Pivot
> Issue Type: Bug
> Components: core-beans, core-json, core-serialization
> Affects Versions: 2.0
> Reporter: Augustus Thoo
> Assignee: Sandro Martini
> Priority: Minor
> Fix For: 2.0.1
>
> Attachments: BeanAdapterTest.java, TestObject.java, patch.patch
>
>
> JSONSerializer would throw an IllegalArgumentException "Unable to coerce
> double to BigDecimal" when the object class contains at least one BigDecimal
> field.
> Exception is traced to BeanAdapter.java , line 916, where coerce(Object,
> Class) has no else-if for BigDecimal class.
> Re:
> http://apache-pivot-users.399431.n3.nabble.com/JSONSerializer-can-t-deserialize-to-BigDecimal-td2464302.html
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira