1 | // Copyright (c) .NET Foundation. All rights reserved.
|
2 | // Licensed under the MIT License.
|
3 |
|
4 | export function toCamelCaseValue(data: unknown): unknown {
|
5 | if (typeof data !== 'object' || data === null) {
|
6 | return data;
|
7 | } else if (Array.isArray(data)) {
|
8 | return data.map(toCamelCaseValue);
|
9 | } else {
|
10 | const result = {};
|
11 | for (const [key, value] of Object.entries(data)) {
|
12 | result[toCamelCaseKey(key)] = toCamelCaseValue(value);
|
13 | }
|
14 | return result;
|
15 | }
|
16 | }
|
17 |
|
18 | export function toCamelCaseKey(key: string): string {
|
19 | return key.charAt(0).toLowerCase() + key.slice(1);
|
20 | }
|