summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/databinding-json/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-09-08 11:30:41 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-09-08 11:30:41 +0000
commit86f8397dbc7f8c5da94ef4f06019420953100c5c (patch)
tree4a0f5a5aeca89fd768cbd1f70939d0606e510d96 /sca-java-2.x/trunk/modules/databinding-json/src
parent5a7306e0e7873abb952cf38ef4f6bb93d5e6409a (diff)
TUSCANY-3668 - support BigDecimal in JSON format and JSONRPC binding. BigDecimal is detected in an interface as a Java simple type but you have to manage it explicitly when converting from primitive types.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@994995 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/databinding-json/src')
-rw-r--r--sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java b/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java
index f405d2b687..d543d0554a 100644
--- a/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java
+++ b/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.databinding.json.jackson;
+import java.math.BigDecimal;
+
import org.apache.tuscany.sca.databinding.PullTransformer;
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.TransformationException;
@@ -57,8 +59,12 @@ public class Object2JSON implements PullTransformer<Object, Object> {
return source;
}
String value = mapper.writeValueAsString(source);
- if (targetType == String.class || targetType == Object.class || targetType.isPrimitive()) {
+ if (targetType == String.class ||
+ targetType == Object.class ||
+ targetType.isPrimitive()) {
return value;
+ } else if (targetType == BigDecimal.class){
+ return value.toString();
} else if (JsonNode.class.isAssignableFrom(targetType)) {
return JacksonHelper.createJsonParser(value).readValueAsTree();
}