From de22dbb220798b23f369e9685a49ac23c3af14b5 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 22 Dec 2014 17:07:19 +0200 Subject: Make SDM work again (#15452) Only import the Json part of elemental and avoid using JsonUtil, which causes https://code.google.com/p/google-web-toolkit/issues/detail?id=9083 Change-Id: I7b93b18ad47b81b2e5bb3947b04bf4550ddd035c --- client/src/com/vaadin/Vaadin.gwt.xml | 2 +- client/src/com/vaadin/client/Util.java | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'client') diff --git a/client/src/com/vaadin/Vaadin.gwt.xml b/client/src/com/vaadin/Vaadin.gwt.xml index 40fbeb5a7a..7387d0f997 100644 --- a/client/src/com/vaadin/Vaadin.gwt.xml +++ b/client/src/com/vaadin/Vaadin.gwt.xml @@ -10,7 +10,7 @@ - + diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index ed9cfce062..8b23bf433b 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -60,9 +60,7 @@ import com.vaadin.shared.ui.ComponentStateUtil; import com.vaadin.shared.util.SharedUtil; import elemental.js.json.JsJsonValue; -import elemental.js.util.Json; import elemental.json.JsonValue; -import elemental.json.impl.JsonUtil; public class Util { @@ -1552,7 +1550,7 @@ public class Util { if (GWT.isProdMode()) { return (T) jso. cast(); } else { - return JsonUtil.parse(Json.stringify(jso)); + return elemental.json.Json.instance().parse(stringify(jso)); } } @@ -1569,10 +1567,36 @@ public class Util { if (GWT.isProdMode()) { return ((JavaScriptObject) jsonValue.toNative()).cast(); } else { - return Json.parse(jsonValue.toJson()); + return parse(jsonValue.toJson()); } } + /** + * Convert a {@link JavaScriptObject} into a string representation. + * + * @param json + * a JavaScript object to be converted to a string + * @return JSON in string representation + */ + private native static String stringify(JavaScriptObject json) + /*-{ + return JSON.stringify(json); + }-*/; + + /** + * Parse a string containing JSON into a {@link JavaScriptObject}. + * + * @param + * the overlay type to expect from the parse + * @param jsonAsString + * @return a JavaScript object constructed from the parse + */ + public native static T parse( + String jsonAsString) + /*-{ + return JSON.parse(jsonAsString); + }-*/; + /** * The allowed value inaccuracy when comparing two double-typed pixel * values. -- cgit v1.2.3