AvroToJson { public byte[] objectToJson(Object msg) throws Exception { return objMapper.writeValueAsBytes(msg); } AvroToJson();  AvroToJson(AvroToJSONCustomizer customizer); byte[] objectToJson(Object msg); T jsonToObject(byte[] bytes, Class<T> klaz);  }
@Test public void testObjectToJson() throws Exception { AvroToJson avroToJson = new AvroToJson(); Thing thing = new Thing(); ObjectMapper objectMapper = new ObjectMapper(); byte[] jsonBytes = avroToJson.objectToJson(thing); Map<String,String> obj = objectMapper.readValue(jsonBytes, Map.class); assertEquals("hi", obj.get("foo")); assertEquals("hello", obj.get("bar")); String jsonStr = new String(jsonBytes, StandardCharsets.UTF_8); assertTrue(jsonStr.contains("\"bar\":\"hello\"")); }