in sdk/core/azure-core-jackson/src/main/java/com/azure/android/core/serde/jackson/FlatteningSerializer.java [113:161]
private void escapeMapKeys(Object value) {
if (value == null) {
return;
}
if (value.getClass().isPrimitive()
|| value.getClass().isEnum()
|| value instanceof OffsetDateTime
|| value instanceof Duration
|| value instanceof String) {
return;
}
int mod = value.getClass().getModifiers();
if (Modifier.isFinal(mod) || Modifier.isStatic(mod)) {
return;
}
if (value instanceof List<?>) {
for (Object val : ((List<?>) value)) {
escapeMapKeys(val);
}
return;
}
if (value instanceof Map<?, ?>) {
for (String key : new HashSet<>(((Map<String, Object>) value).keySet())) {
if (key.contains(".")) {
String newKey = UNESCAPED_PERIOD_PATTERN.matcher(key).replaceAll("\\\\.");
Object val = ((Map<String, Object>) value).remove(key);
((Map<String, Object>) value).put(newKey, val);
}
}
for (Object val : ((Map<?, ?>) value).values()) {
escapeMapKeys(val);
}
return;
}
for (Field f : getAllDeclaredFields(value.getClass())) {
f.setAccessible(true);
try {
escapeMapKeys(f.get(value));
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
// throw logger.logExceptionAsError(new RuntimeException(e));
}
}
}