AvroToJson { public <T> T jsonToObject(byte[] bytes, Class<T> klaz) throws IOException { return objMapper.readValue(bytes, klaz); } AvroToJson();  AvroToJson(AvroToJSONCustomizer customizer); byte[] objectToJson(Object msg); T jsonToObject(byte[] bytes, Class<T> klaz);  }
@Test public void testJsonToObject() throws Exception { AvroToJson avroToJson = new AvroToJson(); User expectedUser = User.newBuilder().setAge(5).setName("Bumpkin").build(); String jsonStr = "{\"name\":\"Bumpkin\",\"age\":5}"; User user = avroToJson.jsonToObject(jsonStr.getBytes(StandardCharsets.UTF_8), User.class); assertEquals(expectedUser, user); }