@Test public void testDeserialize_CDCQueryResponse() throws SerializationException { String xmlResponse = "{\"CDCResponse\":[{\"QueryResponse\":[{\"Deposit\":[{\"DepositToAccountRef\":{\"value\":\"653\",\"name\":\"Bank (102028346)\"},\"TotalAmt\":100,\"HomeTotalAmt\":100,\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"12037\",\"SyncToken\":\"0\",\"MetaData\":{\"CreateTime\":\"2015-09-07T03:31:54-07:00\",\"LastUpdatedTime\":\"2015-09-07T03:31:54-07:00\"},\"TxnDate\":\"2015-09-07\",\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"ExchangeRate\":1,\"PrivateNote\":\"PrivateNote8691daaa\",\"Line\":[{\"Id\":\"1\",\"LineNum\":1,\"Description\":\"Description\",\"Amount\":100,\"DetailType\":\"DepositLineDetail\",\"DepositLineDetail\":{\"Entity\":{\"value\":\"116\",\"name\":\"$%^(&\",\"type\":\"CUSTOMER\"},\"AccountRef\":{\"value\":\"8342\",\"name\":\"Name_7e5e3cec92a74dd09bd264bc5aa19af1\"},\"PaymentMethodRef\":{\"value\":\"707\",\"name\":\"CreditCard20b99ee9341d4\"}}}]},{\"DepositToAccountRef\":{\"value\":\"653\",\"name\":\"Bank (102028346)\"},\"TotalAmt\":100,\"HomeTotalAmt\":100,\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"12039\",\"SyncToken\":\"0\",\"MetaData\":{\"CreateTime\":\"2015-09-07T03:32:19-07:00\",\"LastUpdatedTime\":\"2015-09-07T03:32:19-07:00\"},\"TxnDate\":\"2015-09-07\",\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"ExchangeRate\":1,\"PrivateNote\":\"PrivateNote63bf961f\",\"Line\":[{\"Id\":\"1\",\"LineNum\":1,\"Description\":\"Description\",\"Amount\":100,\"DetailType\":\"DepositLineDetail\",\"DepositLineDetail\":{\"Entity\":{\"value\":\"116\",\"name\":\"$%^(&\",\"type\":\"CUSTOMER\"},\"AccountRef\":{\"value\":\"8344\",\"name\":\"Name_10176b52b2b0460a9bb7ef487f856ff8\"},\"PaymentMethodRef\":{\"value\":\"709\",\"name\":\"CreditCardb661720ccb144\"}}}]}]}]}],\"time\":\"2015-09-08T17:31:09.172-07:00\"}"; IntuitResponse intuitResponse = (IntuitResponse) jsonObj.deserialize(xmlResponse, IntuitResponse.class); Deposit deposit = (Deposit) intuitResponse.getCDCResponse().get(0).getQueryResponse().get(0).getIntuitObject().get(0).getValue(); }
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);  }