Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Recent changes to JSONEncoder?

    I'm seeing some differences with JSONEncoder in the latest 3.1d builds. Code that was producing something like this when encoding a RecordList with a single record with field names c, s and u ...

    [{"c":202,"s":2046,"u":10}]

    Is now producing something like this, with a reference to the Record object ...

    [{"__ref":com.smartgwt.client.data.Record@262f1670,"c":202,"s":2046,"u":10}]

    Calling JSON.decode with that string results in JavaScriptException: (SyntaxError): missing } after property list

    Here is the full stack.
    Code:
    Caused by: com.google.gwt.core.client.JavaScriptException: (SyntaxError): missing } after property list
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.util.JSON.decode(JSON.java)
        at com.islandpacific.gui.client.purchasing.productionorder.ProductionPackEditor.extractPackDetails(ProductionPackEditor.java:289)
        at com.islandpacific.gui.client.purchasing.productionorder.ProductionPackEditor.showWindow(ProductionPackEditor.java:221)
        at com.islandpacific.gui.client.purchasing.productionorder.DeliveryTab$11.onClick(DeliveryTab.java:691)
        at com.smartgwt.client.widgets.menu.events.MenuItemClickEvent.dispatch(MenuItemClickEvent.java:98)
        at com.smartgwt.client.widgets.menu.events.MenuItemClickEvent.dispatch(MenuItemClickEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:248)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
        at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Thread.java:680)

    #2
    Also getting this error when trying to encode an ArrayList<HashMap<String,String> that looks like this in debug ...

    [{u=1, s=1014, c=2}, {u=1, s=1012, c=2}]

    The stack ...

    Code:
    Caused by: com.google.gwt.core.client.JavaScriptException: (null): null
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.util.JSONEncoder.encode(JSONEncoder.java)
        at com.islandpacific.gui.client.purchasing.productionorder.ProductionPackEditor.prepareFormForSave(ProductionPackEditor.java:672)
        at com.islandpacific.gui.client.purchasing.productionorder.ProductionPackEditor.access$17(ProductionPackEditor.java:644)
        at com.islandpacific.gui.client.purchasing.productionorder.ProductionPackEditor$15.onCloseClick(ProductionPackEditor.java:626)
        at com.smartgwt.client.widgets.events.CloseClickEvent.dispatch(CloseClickEvent.java:99)
        at com.smartgwt.client.widgets.events.CloseClickEvent.dispatch(CloseClickEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:71)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
        at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Thread.java:680)

    Comment


      #3
      SmartClient Version: SNAPSHOT_v8.3d_2012-07-21/PowerEdition Deployment (built 2012-07-21)

      Comment


        #4
        We believe we have fixed this issue. Please try the next nightly build (Aug 4 or greater)

        Thanks
        Isomorphic Software.

        Comment


          #5
          Better, but now when I encode an ArrayList<HashMap<String,String> that looks like this in debug ...

          [{u=1, s=1010, c=102}, {u=1, s=1012, c=102}]

          I get this

          "[{u=1, s=1010, c=102}, {u=1, s=1012, c=102}]"

          The whole thing is surrounded by double-quotes.

          Comment


            #6
            Did This ArrayList / HashMap case ever work?

            JSON.encode expects to be passed a JavaScript object. If passed a native Java object directly it will essentially 'toString()' the object. We have recently made a change to quote the toString()'d output - this ensures that if a developer calls "eval()" on the result of a JSON.encode() call that hit a native java object the eval will be working with valid JS code.

            RecordList / Record objects are JS based, so you can use 'getJsObj()' to pass in the JS equivalents but for other native Java objects we would expect you to need to do a conversion, possibly using JSOHelper or similar.
            We do handle this kind of conversion automatically when sending Request parameters to and from the SmartClient server but if you're just calling JSON.encode() and passing in Java Objects directly from application code this wouldn't be supported.
            If this is something that was working for you before and is recently broken, we may need to see a test case so we're sure we understand your usage.

            Thanks
            Isomorphic Software

            Comment


              #7
              Actually I changed to ArrayList / HashMap to try to avoid the original problem of the inclusion of the "__ref" attribute. I've reverted back to the original code and it is working fine now.

              Thanks!

              Comment

              Working...
              X