/** * Change encoding of uuids from <b>latin1 (ISO-8859-1)</b> to <b>base64</b>. * * @param json the json that should be processed * @return the json with changed uuids * @throws IOException the io exception */ public static JsonNode encodeUuids(JsonNode json) throws IOException { if (json.has(UUID_FIELD)) { JsonNode jsonNode = json.get(UUID_FIELD); if (jsonNode.has(UUID_VALUE)) { String value = jsonNode.get(UUID_VALUE).asText(); String encodedValue = Base64.getEncoder().encodeToString(value.getBytes("ISO-8859-1")); ((ObjectNode) jsonNode).put(UUID_VALUE, encodedValue); } } for (JsonNode node : json) { if (node.isContainerNode()) { encodeUuids(node); } } return json; }
/** * Removes UUIDs from a json tree. * * @param json json tree node */ public static void removeUuids(JsonNode json) { boolean containerWithId = json.isContainerNode() && json.has(UUID_FIELD); boolean isArray = json.isArray(); boolean childIsNotArray = !(json.size() == 1 && json.getElements().next().isArray()); if (containerWithId && !isArray && childIsNotArray) { ((ObjectNode) json).remove(UUID_FIELD); } for (JsonNode node : json) { if (node.isContainerNode()) { removeUuids(node); } } } }
public boolean isContainerNode() { return delegate.isContainerNode(); }
private static Map<String, Object> extractMeasuresFromComplexType(final String parentMeasureName, final JsonNode jsonNode) { final Map<String, Object> unwrappedValues = new HashMap<String, Object>(); if (jsonNode.isContainerNode()) { final Iterator<Entry<String, JsonNode>> i = jsonNode.getFields(); while (i.hasNext()) { final Entry<String, JsonNode> childEntry = i.next(); unwrappedValues.putAll(extractMeasuresFromComplexType(parentMeasureName + "." + childEntry.getKey(), childEntry.getValue())); } } else { final String measureName = parentMeasureName; try { final Object value = getSimpleValue(jsonNode.asText()); unwrappedValues.put(measureName, value); } catch (final ParseException pe) { // probably String or some non-numeric value. Pass } } return unwrappedValues; }
String currentKey = elt.getKey(); if(currentNode.isContainerNode())