Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Last active April 18, 2021 00:51
Show Gist options
  • Save ltfschoen/79ab3e98723e61660117 to your computer and use it in GitHub Desktop.
Save ltfschoen/79ab3e98723e61660117 to your computer and use it in GitHub Desktop.
Object(keys) Helper Function for ExtendScript
// 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
@Nazaroni
Copy link

Do you have something similar to get the values from JSON?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment