Created
July 31, 2019 06:21
-
-
Save skunkie/9863e235aa8ad05d699485b0f18e1b92 to your computer and use it in GitHub Desktop.
VMware vRealize Orchestrator Action: Create Properties from Object
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
/** | |
* Create Properties from Object | |
* @param {Object} obj Object | |
* @return {Properties} Properties | |
*/ | |
function createProperties(obj) { | |
var props = new Properties(); | |
for (var key in obj) { | |
// process Array | |
if (obj[key] instanceof Array) { | |
for (var i = 0; i < obj[key].length; i++) { | |
props.put(key, createProperties(obj[key][i])); | |
} | |
// process Object | |
} else if (obj[key] instanceof Object) { | |
props.put(key, createProperties(obj[key])); | |
// process other types | |
} else props.put(key, obj[key]); | |
} | |
return props; | |
} | |
return createProperties(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment