private Parser createJsonParser(String queryScope, String input) { Parser parser = new JsonParser(input); if (!HttpAdapter.createResponseWrangling(queryScope, this).getRecordSelector().isEmpty()) { ((JsonParser) parser) .setRootElement( parser.parse( HttpAdapter.createResponseWrangling(queryScope, this).getRecordSelector(), JsonElement.class)); } return parser; }
public RemoteObject deserialize(String queryScope, Parser parser) { final RouterAdapter routerAdapter = RemoteRailsConfig.getRouterAdapterByClass(this.getClass()); CapitalMarketsOrder object = new CapitalMarketsOrder(); HttpAdapter.Configuration configuration = null; if ((routerAdapter != null) && (routerAdapter instanceof HttpAdapter)) { if (queryScope != null && !queryScope.isEmpty()) { configuration = ((HttpAdapter) routerAdapter).getScopedConfigurationsByNameAsConfiguration(queryScope); } else { configuration = ((HttpAdapter) routerAdapter).getConfigurationsAsConfiguration("GET"); } } if (configuration != null) { try { object.id = parser.parse(configuration.getResponseRemoteFieldName("id"), ObjectId.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.comments = parser.parse(configuration.getResponseRemoteFieldName("comments"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.currency = parser.parse(configuration.getResponseRemoteFieldName("currency"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.lastPrice = parser.parse(configuration.getResponseRemoteFieldName("last_price"), Float.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.lastQty = parser.parse(configuration.getResponseRemoteFieldName("last_qty"), Integer.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.price = parser.parse(configuration.getResponseRemoteFieldName("price"), Float.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.quantity = parser.parse(configuration.getResponseRemoteFieldName("quantity"), Integer.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.side = parser.parse(configuration.getResponseRemoteFieldName("side"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.status = parser.parse(configuration.getResponseRemoteFieldName("status"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.symbol = parser.parse(configuration.getResponseRemoteFieldName("symbol"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } try { object.transactTime = parser.parse(configuration.getResponseRemoteFieldName("transact_time"), String.class); } catch (PathNotFoundException e) { log.info("Unable to deserialize field: " + e.getMessage()); } } else { // Default to use gson deserializer String json = ""; if (parser instanceof JsonParser) { json = ((JsonParser) parser).getRootElement().toString(); } object = (CapitalMarketsOrder) Utilities.transformJsonToObject(json, this.getClass()); } return object; }