Source:
public Metric deserialize(JsonParser jp, DeserializationContext dc) throws IOException { JsonNode node = jp.getCodec().readTree(jp); ObjectMapper mapper = new ObjectMapper(); Map<Long, String> datapoints = mapper.readValue(node.get("dps").traverse(), new TypeReference<TreeMap<Long, String>>() { }); Map<String, String> tags = mapper.readValue(node.get("tags").traverse(), new TypeReference<Map<String, String>>() { }); Map<String, String> meta = fromMeta(tags.get(ReservedField.META.getKey())); String tsdbMetricName = node.get("metric").asText(); TSDBService tsdbService = SystemMain.getInstance().getServiceFactory().getTSDBService(); String scope = tsdbService.getScopeFromTSDBMetric(tsdbMetricName); String namespace = tsdbService.getNamespaceFromTSDBMetric(tsdbMetricName); if (scope.isEmpty()) { return null; } String metric = tags.get(ReservedField.METRIC.getKey()); Map<String, String> userTags = new HashMap<>(); for (Map.Entry<String, String> entry : tags.entrySet()) { String key = entry.getKey(); if (!ReservedField.isReservedField(key)) { userTags.put(key, entry.getValue()); } } Metric result = new Metric(scope, metric); if (meta != null) { String displayName = meta.get(ReservedField.DISPLAY_NAME.getKey()); String units = meta.get(ReservedField.UNITS.getKey()); result.setDisplayName(displayName); result.setUnits(units); } result.setTags(userTags); result.setDatapoints(datapoints); if (namespace != null) { result.setNamespace(namespace); } Iterator<JsonNode> tsuidsIter = node.get("tsuids").elements(); String tsuid = tsuidsIter.next().asText(); try { Field tsuidField = TSDBEntity.class.getDeclaredField("_uid"); tsuidField.setAccessible(true); tsuidField.set(result, tsuid); } catch (Exception ex) { throw new IOException(ex); } return result; }

Target:
public Metric deserialize(JsonParser jp, DeserializationContext dc) throws IOException { JsonNode node = jp.getCodec().readTree(jp); ObjectMapper mapper = new ObjectMapper(); Map<Long, String> datapoints = mapper.readValue(node.get("dps").traverse(), new TypeReference<TreeMap<Long, String>>() { }); Map<String, String> tags = mapper.readValue(node.get("tags").traverse(), new TypeReference<Map<String, String>>() { }); Map<String, String> meta = fromMeta(tags.get(ReservedField.META.getKey())); String tsdbMetricName = node.get("metric").asText(); String scope = tsdbService.getScopeFromTSDBMetric(tsdbMetricName); String namespace = tsdbService.getNamespaceFromTSDBMetric(tsdbMetricName); if (scope.isEmpty()) { return null; } String metric = tags.get(ReservedField.METRIC.getKey()); Map<String, String> userTags = new HashMap<>(); for (Map.Entry<String, String> entry : tags.entrySet()) { String key = entry.getKey(); if (!ReservedField.isReservedField(key)) { userTags.put(key, entry.getValue()); } } Metric result = new Metric(scope, metric); if (meta != null) { String displayName = meta.get(ReservedField.DISPLAY_NAME.getKey()); String units = meta.get(ReservedField.UNITS.getKey()); result.setDisplayName(displayName); result.setUnits(units); } result.setTags(userTags); result.setDatapoints(datapoints); if (namespace != null) { result.setNamespace(namespace); } Iterator<JsonNode> tsuidsIter = node.get("tsuids").elements(); String tsuid = tsuidsIter.next().asText(); try { Field tsuidField = TSDBEntity.class.getDeclaredField("_uid"); tsuidField.setAccessible(true); tsuidField.set(result, tsuid); } catch (Exception ex) { throw new IOException(ex); } return result; }