Java Code Examples for com.dslplatform.json.JsonWriter#toStream()
The following examples show how to use
com.dslplatform.json.JsonWriter#toStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdatesServlet.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("application/json"); final int count = Utils.parseBoundParam(req); final Context ctx = Utils.getContext(); final JsonWriter json = Utils.getJson(); final World[] worlds = ctx.loadWorldsSlow(count); final ArrayList<World> changed = new ArrayList<>(count); for (int i = 0; i < count; i++) { changed.add(worlds[i].setRandomNumber(ctx.getRandom10k())); } changed.sort(ASC); ctx.worlds.update(changed); json.serialize(worlds, count); json.toStream(res.getOutputStream()); }
Example 2
Source File: QueriesServlet.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("application/json"); final int count = Utils.parseBoundParam(req); final Context ctx = Utils.getContext(); final JsonWriter json = Utils.getJson(); final World[] worlds = ctx.loadWorldsSlow(count); json.serialize(worlds, count); json.toStream(res.getOutputStream()); }
Example 3
Source File: DbServlet.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("application/json"); final Context ctx = Utils.getContext(); final Optional<World> world = ctx.worlds.find(ctx.getRandom10k(), ctx.connection); final JsonWriter writer = Utils.getJson(); world.get().serialize(writer, false); writer.toStream(res.getOutputStream()); }
Example 4
Source File: JsonServlet.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("application/json"); final Message msg = new Message("Hello, World!"); final JsonWriter writer = Utils.getJson(); msg.serialize(writer, false); writer.toStream(res.getOutputStream()); }