vertx-eventbus-bridge-clients icon indicating copy to clipboard operation
vertx-eventbus-bridge-clients copied to clipboard

EventBus doesn't encode JsonObject correctly

Open shvalb opened this issue 2 years ago • 0 comments

Version

Version 1.0.1

Context

Sending a simple JsonObject is encoded incorrectly via Jackson or Gson.

Reproducer

JsonObject json = new JsonObject().put("login", new JsonObject());
JsonCodec codec = new JacksonCodec();
String str = codec.encode(json);

Expected str = "{"login": {}}"

Actual str = {"map":{"login":{"map":{},"empty":true}},"empty":false}

Conclusion The Jackson encoder implementation doesn't know how to encode a Map correctly.

Suggested Solution Replace: io.vertx.eventbusclient.json.JsonCodec with io.vertx.core.spi.json.JsonCodec io.vertx.eventbusclient.json.JacksonCodec with io.vertx.core.json.jackson.JacksonCodec

Implement a new GsonCodec in io.vertx.core.json

shvalb avatar Nov 23 '22 04:11 shvalb