@Test public void testDeserialize_QueryResponse() throws SerializationException { String xmlResponse = "{\"QueryResponse\":{\"Account\":[{\"Name\":\"Accounts Receivable_ae079\",\"SubAccount\":false,\"Description\":\"Updated @ 2015-09-10T11:15:59-05:00\",\"FullyQualifiedName\":\"Accounts Receivable_ae079\",\"Active\":true,\"Classification\":\"Asset\",\"AccountType\":\"Accounts Receivable\",\"AccountSubType\":\"AccountsReceivable\",\"CurrentBalance\":-646.8,\"CurrentBalanceWithSubAccounts\":-646.8,\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"13320\",\"SyncToken\":\"1\",\"MetaData\":{\"CreateTime\":\"2015-09-10T05:23:47-07:00\",\"LastUpdatedTime\":\"2015-09-10T12:44:57-07:00\"}},{\"Name\":\"Acct10007519461569892922\",\"SubAccount\":false,\"Description\":\"Originally created @ 2015-09-09T16:13:21-05:00\",\"FullyQualifiedName\":\"Acct10007519461569892922\",\"Active\":true,\"Classification\":\"Expense\",\"AccountType\":\"Expense\",\"AccountSubType\":\"Travel\",\"CurrentBalance\":0,\"CurrentBalanceWithSubAccounts\":0,\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"12079\",\"SyncToken\":\"0\",\"MetaData\":{\"CreateTime\":\"2015-09-09T14:13:21-07:00\",\"LastUpdatedTime\":\"2015-09-09T14:13:21-07:00\"}},{\"Name\":\"Acct10115087251982090345\",\"SubAccount\":false,\"Description\":\"Updated @ 2015-09-04T11:15:47-05:00\",\"FullyQualifiedName\":\"Acct10115087251982090345\",\"Active\":true,\"Classification\":\"Expense\",\"AccountType\":\"Expense\",\"AccountSubType\":\"Travel\",\"CurrentBalance\":0,\"CurrentBalanceWithSubAccounts\":0,\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"636\",\"SyncToken\":\"1\",\"MetaData\":{\"CreateTime\":\"2015-08-25T09:43:27-07:00\",\"LastUpdatedTime\":\"2015-09-04T09:23:16-07:00\"}},{\"Name\":\"Acct1012566432148149940\",\"SubAccount\":false,\"Description\":\"Updated @ 2015-08-27T11:15:35-05:00\",\"FullyQualifiedName\":\"Acct1012566432148149940\",\"Active\":true,\"Classification\":\"Expense\",\"AccountType\":\"Expense\",\"AccountSubType\":\"Travel\",\"CurrentBalance\":0,\"CurrentBalanceWithSubAccounts\":0,\"CurrencyRef\":{\"value\":\"USD\",\"name\":\"United States Dollar\"},\"domain\":\"QBO\",\"sparse\":false,\"Id\":\"1688\",\"SyncToken\":\"1\",\"MetaData\":{\"CreateTime\":\"2015-08-27T09:19:25-07:00\",\"LastUpdatedTime\":\"2015-08-27T09:19:26-07:00\"}}],\"startPosition\":1,\"maxResults\":100},\"time\":\"2015-09-10T13:53:18.893-07:00\"}"; IntuitResponse intuitResponse = (IntuitResponse) jsonObj.deserialize(xmlResponse, IntuitResponse.class); Account account = (Account) intuitResponse.getQueryResponse().getIntuitObject().get(0).getValue(); Assert.assertEquals(account.getCurrentBalance(), new BigDecimal("-646.80")); }
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);  }