From c9efcb7cf9742fd31ce421f29b78a9c045a46d15 Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 10 Oct 2011 21:15:41 +0000 Subject: Use Jackson JsonNode as the unified representation of json data git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1181240 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/databinding/json/jackson/Object2JSON.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sca-java-2.x/trunk/modules/databinding-json') 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 38b826b202..2b77054934 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 @@ -58,14 +58,13 @@ public class Object2JSON implements PullTransformer { } ObjectMapper mapper = JacksonHelper.createObjectMapper(targetType); String value = mapper.writeValueAsString(source); - if (targetType == String.class || targetType == Object.class || targetType.isPrimitive()) { + if (JsonNode.class.isAssignableFrom(targetType)) { + return JacksonHelper.createJsonParser(value).readValueAsTree(); + } else 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(); - } - if (JsonParser.class.isAssignableFrom(targetType)) { + } else if (JsonParser.class.isAssignableFrom(targetType)) { return JacksonHelper.createJsonParser(value); } else { return JSONHelper.toJSON(value, targetType); -- cgit v1.2.3