0

I have written a simple native method in GWT code as below:

public static native JavaScriptObject parseString(String jsonString) /*-{
        return JSON.parse(jsonString);

    }-*/;

Now I have GWTTestCase to validate this code but the test case is failing due to com.google.gwt.core.client.JavaScriptException.

When I pass same string to another method which is using java script eval() method internally, it is able to parse string appropriately.

So, does anyone have clue what could be the issue with JSON.parse(string) ?

vsbehere
  • 666
  • 1
  • 7
  • 23
  • Are you testing in a real browser or in htmunit ? Which version of GWT ? Also, you don't need that method, JsonUtils will use native `JSON.parse` when available (i.e. always, legacy from old IE support) – Thomas Broyer Jan 04 '17 at 07:04
  • htmunit browser. GWT 2.7, actually I want to write custom native code so I am not using JsonUtils. – vsbehere Jan 05 '17 at 05:57
  • Does it change anything if you use `$wnd.JSON` instead of `JSON`? – Thomas Broyer Jan 06 '17 at 07:12

0 Answers0