@Test public void testDeserialize_Report() throws SerializationException { String json = "{\"time\":\"2012-08-14T07:25:33.111Z\",\"requestId\":\"123\",\"status\":\"pending\",\"Report\":{\"domain\":\"Validation\"}}"; IntuitResponse intuitResponse = (IntuitResponse) jsonObj.deserialize(json, IntuitResponse.class); Assert.assertNotNull(intuitResponse.getReport()); }
public Response deserialize(String json, Class<?> cl) throws SerializationException { Response intuitResponse = null; ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer()); mapper.registerModule(simpleModule); simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer()); mapper.registerModule(simpleModule); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { if(cl.getName().equalsIgnoreCase("com.intuit.ipp.data.TaxService")) { intuitResponse = (Response) mapper.readValue(json, TaxService.class); } else { intuitResponse = mapper.readValue(json, IntuitResponse.class); } } catch (Exception e) { LOG.error("Exception while json deserialize", e); throw new SerializationException(e); } return intuitResponse; }
JSONSerializer implements IEntitySerializer { public Response deserialize(String json, Class<?> cl) throws SerializationException { Response intuitResponse = null; ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer()); mapper.registerModule(simpleModule); simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer()); mapper.registerModule(simpleModule); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { if(cl.getName().equalsIgnoreCase("com.intuit.ipp.data.TaxService")) { intuitResponse = (Response) mapper.readValue(json, TaxService.class); } else { intuitResponse = mapper.readValue(json, IntuitResponse.class); } } catch (Exception e) { LOG.error("Exception while json deserialize", e); throw new SerializationException(e); } return intuitResponse; } }
JSONSerializer implements IEntitySerializer { public Response deserialize(String json, Class<?> cl) throws SerializationException { Response intuitResponse = null; ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer()); mapper.registerModule(simpleModule); simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer()); mapper.registerModule(simpleModule); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { if(cl.getName().equalsIgnoreCase("com.intuit.ipp.data.TaxService")) { intuitResponse = (Response) mapper.readValue(json, TaxService.class); } else { intuitResponse = mapper.readValue(json, IntuitResponse.class); } } catch (Exception e) { LOG.error("Exception while json deserialize", e); throw new SerializationException(e); } return intuitResponse; }  }
JSONSerializer implements IEntitySerializer { public Response deserialize(String json, Class<?> cl) throws SerializationException { Response intuitResponse = null; ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer()); mapper.registerModule(simpleModule); simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer()); mapper.registerModule(simpleModule); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { if(cl.getName().equalsIgnoreCase("com.intuit.ipp.data.TaxService")) { intuitResponse = (Response) mapper.readValue(json, TaxService.class); } else { intuitResponse = mapper.readValue(json, IntuitResponse.class); } } catch (Exception e) { LOG.error("Exception while json deserialize", e); throw new SerializationException(e); } return intuitResponse; }  @SuppressWarnings("unchecked") String serialize(T object); Response deserialize(String json, Class<?> cl); @Override Response deserializeEntitlements(String decompressedData, Class<EntitlementsResponse> cl); }
JSONSerializer implements IEntitySerializer { public Response deserialize(String json, Class<?> cl) throws SerializationException { Response intuitResponse = null; ObjectMapper mapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule("IntuitResponseDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(IntuitResponse.class, new IntuitResponseDeserializer()); mapper.registerModule(simpleModule); simpleModule = new SimpleModule("TaxServiceDeserializer", new Version(1, 0, 0, null)); simpleModule.addDeserializer(TaxService.class, new TaxServiceDeserializer()); mapper.registerModule(simpleModule); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { if(cl.getName().equalsIgnoreCase("com.intuit.ipp.data.TaxService")) { intuitResponse = (Response) mapper.readValue(json, TaxService.class); } else { intuitResponse = mapper.readValue(json, IntuitResponse.class); } } catch (Exception e) { LOG.error("Exception while json deserialize", e); throw new SerializationException(e); } return intuitResponse; }  @SuppressWarnings("unchecked") String serialize(T object); Response deserialize(String json, Class<?> cl); @Override Response deserializeEntitlements(String decompressedData, Class<EntitlementsResponse> cl);  }