in libraries/azure-app-configuration-importer/src/internal/parsers/defaultConfigurationSettingsConverter.ts [121:161]
private toConfigurationSettings(
flatted: any,
options: SourceOptions
): Array<SetConfigurationSettingParam<string>> {
const result = new Array<SetConfigurationSettingParam>();
const isJsonType = isJsonContentType(options.contentType);
for (const element in flatted) {
let generateKey: string = element;
if (options.prefix) {
generateKey = options.prefix + element;
}
if (generateKey === "." || generateKey === ".." || generateKey.indexOf("%") > -1) {
throw new ArgumentError("Key cannot be a '.' or '..', or contain the '%' character.");
}
if (generateKey.startsWith(featureFlagPrefix)) {
throw new ArgumentError("Key cannot start with the reserved prefix for feature flags.");
}
// Ignore key-value with empty array/object value when content-type is not json, instead of pushing a kv with an empty array/obj
// For null value it will be treated as "null" string.
if (!isJsonType && flatted[element] && typeof flatted[element] === "object" && Object.keys(flatted[element]).length == 0 ) {
continue;
}
const setting: SetConfigurationSettingParam<string> = {
label: options.label,
tags: options.tags,
key: generateKey,
contentType: options.contentType,
value:
typeof flatted[element] === "object" || isJsonType
? JSON.stringify(flatted[element])
: flatted[element].toString()
};
result.push(setting);
}
return result;
}