Last active
July 19, 2023 13:27
-
-
Save samson-sham/02bf8de74ed35b98b69621ba5a5b63f7 to your computer and use it in GitHub Desktop.
AWS => CDK config conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const medialiveJSON = require('./config.json'); | |
const isObject = (o) => typeof o === 'object' && !Array.isArray(o); | |
// Not considering N-levels array | |
const lower = (obj) => Object.fromEntries(Object.entries(obj).map(([k,v]) => ([`${k[0].toLowerCase()}${k.slice(1)}`,isObject(v) ? lower(v) : Array.isArray(v) ? v.map(vv => isObject(vv) ? lower(vv) : vv) : v]))); | |
console.log(JSON.stringify(lower(medialiveJSON), null, 4)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment