Parsing the following JSON input and sending the resulting object to the console yields the expected results for a JSNI JSON.parse() but yields incorrect timestamps using a JsInterop JSON.parse() (with correct results for all other properties). I'm completely at a loss as to why. Any suggestions?
JsInterop JSON parser:
-- Input:
{"Contract":"STK:USD:PBA@NYSE","action":"onHistoricalData","bar":"D","bars":[{"close":21.76,"high":21.84,"low":21.38,"open":21.41,"time":1451520000,"volume":3067},{"close":21.56,"high":21.63,"low":21.14,"open":21.37,"time":1451865600,"volume":2565},{"close":21.49,"high":21.57,"low":21.26,"open":21.5,"time":1451952000,"volume":2303}],"callback":4,"metadata":{"noData":false},"t":1482867635,"t0":1451763575,"ticker":"STK:USD:PBA@NYSE"}
JSNI JSON parser:
native static Object parse( String json ) /*-{ return $wnd.JSON.parse( json ); }-*/;
JsInterop JSON parser:
@JsType( isNative = true, namespace = GLOBAL, name = "JSON" )
abstract public class JSON {
native static public <T> T parse( String json );
}
@JsType( isNative = true, namespace = JsPackage.GLOBAL, name = "Object" )
public class Message {
public int callback; // HARD-CODED in conjunction with Service::CALLBACK
}
// json from WebSocket
Window.console.info( parse( json ) );
Message message = JSON.parse( json );
Window.console.debug( message );
console.info:
console.debug:
I tested the code in Chrome, Edge, and Safari and each yielded the same results. Any suggestion as to where things are going awry will be greatly appreciated.
Dave
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment