/* * Copyright 2022 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ /** * Converts a config row-based name/value pair array with dotted key notation to an object. * * example: * * ``` * host: www.adobe.com * document.level: 42, * document.title: hello * document.body.status: 200 * acl.allow: /foo * acl.allow: /bar * cnd.0.type: fastly * cnd.0.host: www.adobe.com * cnd.1.type: cloudflare * ``` * * becomes: * * ``` * { * host: 'www.adobe.com', * document: { * level: 42, * title: 'hello', * body: { * status: 200, * } * }, * acl: { * allow: ['/foo', '/bar], * } * cnd: [ * { type: 'fastly', host: 'www.adobe.com' }, * { type: 'cloudflare' }, * ] * } * ``` * * @param {object[]} rows array of columns * @param {string} [keyName = 'key'] name of the key column. * @param {string} [valueName = 'value'] name of the value column. */ export function flatJson2object(rows:object[], keyName:string, valueName:string);