diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-10 21:15:41 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-10-10 21:15:41 +0000 |
commit | c9efcb7cf9742fd31ce421f29b78a9c045a46d15 (patch) | |
tree | 85df6f81bff1191b423fd102d12acaded3caab2f /sca-java-2.x/trunk/modules/databinding-json/src/main | |
parent | 20b39ce21277493dced135f09cca0dd02eca8087 (diff) |
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/databinding-json/src/main')
-rw-r--r-- | sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/Object2JSON.java | 9 |
1 files changed, 4 insertions, 5 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 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<Object, Object> { } 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); |