Last active
April 18, 2021 00:51
-
-
Save ltfschoen/79ab3e98723e61660117 to your computer and use it in GitHub Desktop.
Object(keys) Helper Function for ExtendScript
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
// Custom Helper function for ExtendScript (Adobe CEP) created as an alternative since JavaScript Object(keys) method does not work | |
var getKeysWithoutObjectKeysSupport = function(associativeArrayObject) { | |
var arrayWithKeys=[], associativeArrayObject; | |
for (key in associativeArrayObject) { | |
// Avoid returning these keys from the Associative Array that are stored in it for some reason | |
if (key !== undefined && key !== "toJSONString" && key !== "parseJSON" ) { | |
arrayWithKeys.push(key); | |
} | |
} | |
return arrayWithKeys; | |
} | |
var myAssociativeArrayObject = { | |
'name': 'Luke', | |
'language': 'ExtendScript', | |
'compatibility': 'none' | |
}; | |
var keys = getKeysWithoutObjectKeysSupport(myAssociativeArrayObject); | |
alert(keys); | |
alert(Object.keys(myAssociativeArrayObject)); // JavaScript's Object(keys) method is supported if this works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have something similar to get the values from JSON?