From 35d91245de3218283c8f4c733a3aa72ea395fb1c Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sat, 10 Jan 2015 12:56:52 +0200 Subject: Support JsonValue types as declared types in state and RPC (#15560) Change-Id: I2779a533811bb1b60c4e74789f6378574bc6ac61 --- .../com/vaadin/client/communication/JsonDecoder.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/communication/JsonDecoder.java b/client/src/com/vaadin/client/communication/JsonDecoder.java index a8adbac0c6..0ce89c873e 100644 --- a/client/src/com/vaadin/client/communication/JsonDecoder.java +++ b/client/src/com/vaadin/client/communication/JsonDecoder.java @@ -82,13 +82,16 @@ public class JsonDecoder { */ public static Object decodeValue(Type type, JsonValue jsonValue, Object target, ApplicationConnection connection) { + String baseTypeName = type.getBaseTypeName(); + if (baseTypeName.startsWith("elemental.json.Json")) { + return jsonValue; + } - // Null is null, regardless of type + // Null is null, regardless of type (except JSON) if (jsonValue.getType() == JsonType.NULL) { return null; } - String baseTypeName = type.getBaseTypeName(); if (Map.class.getName().equals(baseTypeName) || HashMap.class.getName().equals(baseTypeName)) { return decodeMap(type, jsonValue, connection); @@ -293,4 +296,14 @@ public class JsonDecoder { tokens.add(decodeValue(childType, entryValue, null, connection)); } } + + /** + * Called by generated deserialization code to treat a generic object as a + * JsonValue. This is needed because GWT refuses to directly cast String + * typed as Object into a JSO. + */ + public static native T obj2jso(Object object) + /*-{ + return object; + }-*/; } -- cgit v1.2.3