You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I want to run an AppleScript similar to this one:
tell current track
set export to {name:name, album:album, artist:artist}
end tell
Which works just fine, except what is returned is an array ['name:name', 'album:album', etc], rather than a keyed hash.
I've had a look at applescript-parser.js and I think UndefinedParser currently the best place for this:
while (!END_OF_TOKEN.test(cur)) {
if (cur === ':') {
var key = this.value.substring(this.index, end-1);
this.index = end;
var value = parseFromFirstRemaining.call(this);
return {key: key, value: value};
}
cur = this.value[end++];
}
Then, in ArrayParser:
if (next.key) {
rtn[next.key] = next.value;
} else{
rtn.push(next);
}
This does need more work though, because it won't determine if rtn should be an array or hash and that creates issues later.
The text was updated successfully, but these errors were encountered:
Here's an ad hoc solution for applescript records, FWIW:
# convert applescript record to a js object# trim off last char, quote the keys before :"# now it looks like json# then fix date and array formatsj=JSON.parseout.slice(0,-1).replace(/(\w+)\:\"/g, '"$1":"')
j.creation_date= (newDatej.creation_date).toJSON()
j.modification_date= (newDatej.modification_date).toJSON()
a=j.position.split(',')
j.position=newArrayparseInt(a[0]), parseInt(a[1])
So I want to run an AppleScript similar to this one:
Which works just fine, except what is returned is an array
['name:name', 'album:album', etc]
, rather than a keyed hash.I've had a look at applescript-parser.js and I think UndefinedParser currently the best place for this:
Then, in ArrayParser:
This does need more work though, because it won't determine if rtn should be an array or hash and that creates issues later.
The text was updated successfully, but these errors were encountered: