FromJsonDeserializer { public Object jsonToObject(String json, Class<?> objectType) { JacksonSerializationEngine engine = new JacksonSerializationEngine(); JacksonSerializationResolver serializationResolver = new JacksonSerializationResolver(); JacksonSerialization jacksonSerialization = serializationResolver.resolveSerialization(objectType); try { return engine.deserialize(json, jacksonSerialization); } catch (Exception e) { e.printStackTrace(); } return null; }  Object jsonToObject(String json, Class<?> objectType); BristleMessage<String[]> jsonToObject(String json);  }
@Test public void shouldSerializeBristleMessageWithPerson() throws Exception { BristleMessage bristleMessage = new BristleMessage(); bristleMessage.withId("123"); bristleMessage.withName("name"); bristleMessage.withPayload(new Person()); BristleMessage<String[]> deserialized = fromJsonDeserializer.jsonToObject("{\"id\":\"123\",\"name\":\"name\",\"payload\":[{\"name\":\"john\",\"age\":12}]}"); assertThat(deserialized.getName()).isEqualTo("name"); }