Skip to content

Instantly share code, notes, and snippets.

@samson-sham
Last active July 19, 2023 13:27
Show Gist options
  • Save samson-sham/02bf8de74ed35b98b69621ba5a5b63f7 to your computer and use it in GitHub Desktop.
Save samson-sham/02bf8de74ed35b98b69621ba5a5b63f7 to your computer and use it in GitHub Desktop.
AWS => CDK config conversion
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