Hi, On Sun, May 29, 2016 at 8:11 PM, Alexander Farber <[email protected]> wrote: > Good evening, > > I have 2 questions related to JSON usage please: > > 1) I have added jetty-util-ajax Maven-package to > https://github.com/afarber/jetty-newbie/blob/master/EmbWebsocketListener/pom.xml > > <dependency> > <groupId>org.eclipse.jetty</groupId> > <artifactId>jetty-util-ajax</artifactId> > <version>9.3.9.v20160517</version> > </dependency> > > But for some reason still can not use > > import org.eclipse.jetty.util.ajax.JSON; > > in Java-files. Is that class for public use or should I better use Gson?
The JSON class is for public use and used, for example, by the CometD project (https://cometd.org). It might just be a problem with your IDE or otherwise some other configuration. > 2) In my custom WebsocketListener implementation at > https://github.com/afarber/jetty-newbie/blob/master/EmbWebsocketListener/src/main/java/org/eclipse/jetty/demo/listener/MyListener.java > > I plan to close connection on all binary messages with > > @Override > public void onWebSocketBinary(byte[] arg0, int arg1, int arg2) { > mSession.close(1003, null); > } > > and all text messages should be parsable JSON > (or I'd like to close connection too). > > Is it possible to register such a "policy" at > my custom WebSocketHandler implementation > https://github.com/afarber/jetty-newbie/blob/master/EmbWebsocketListener/src/main/java/org/eclipse/jetty/demo/listener/MyHandler.java > (I think I've seen such an "annotation" tag > in a servlet-example, but can't find it anymore...) > or should I enforce this manually in onWebSocketText? Manually enforcing it's the way to go. -- Simone Bordet ---- http://cometd.org http://webtide.com Developer advice, training, services and support from the Jetty & CometD experts. _______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
