Codota Logo
BodyCodec.json
Code IndexAdd Codota to your IDE (free)

How to use
json
method
in
io.vertx.rxjava.ext.web.codec.BodyCodec

Best Java code snippets using io.vertx.rxjava.ext.web.codec.BodyCodec.json (Showing top 3 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: vert-x3/vertx-examples

 @Override
 public void start() throws Exception {

  WebClient client = WebClient.create(vertx);
  Single<HttpResponse<Data>> request = client.get(8080, "localhost", "/")
   .as(BodyCodec.json(Data.class))
   .rxSend();

  // Fire the request
  request.subscribe(resp -> System.out.println("Server content " + resp.body().message));

  // Again
  request.subscribe(resp -> System.out.println("Server content " + resp.body().message));

  // And again
  request.subscribe(resp -> System.out.println("Server content " + resp.body().message));
 }
}
origin: vert-x3/vertx-rx

 @Test
 public void testErrorHandling() throws Exception {
  try {
   client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
   Single<HttpResponse<WineAndCheese>> single = client
    .get(-1, "localhost", "/the_uri")
    .as(BodyCodec.json(WineAndCheese.class))
    .rxSend();
   single.subscribe(resp -> fail(), error -> {
    assertEquals(IllegalArgumentException.class, error.getClass());
    testComplete();
   });
   await();
  } catch (Throwable t) {
   fail();
  }
 }
}
origin: vert-x3/vertx-rx

@Test
public void testResponseBodyAsAsJsonMapped() throws Exception {
 JsonObject expected = new JsonObject().put("cheese", "Goat Cheese").put("wine", "Condrieu");
 HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
 server.requestStream().handler(req -> req.response().end(expected.encode()));
 try {
  server.listen(ar -> {
   client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
   Single<HttpResponse<WineAndCheese>> single = client
    .get(8080, "localhost", "/the_uri")
    .as(BodyCodec.json(WineAndCheese.class))
    .rxSend();
   single.subscribe(resp -> {
    assertEquals(200, resp.statusCode());
    assertEquals(new WineAndCheese().setCheese("Goat Cheese").setWine("Condrieu"), resp.body());
    testComplete();
   }, this::fail);
  });
  await();
 } finally {
  server.close();
 }
}
io.vertx.rxjava.ext.web.codecBodyCodecjson

Javadoc

Create and return a codec for Java objects encoded using Jackson mapper.

Popular methods of BodyCodec

  • <init>
  • buffer
  • getDelegate
  • jsonObject
  • newInstance
  • string
    A codec for strings using a specific encoding.

Popular in Java

  • Making http requests using okhttp
  • runOnUiThread (Activity)
  • getApplicationContext (Context)
  • getSystemService (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JList (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now