Extracting a key and value for a single property

I’m trying to extract a single key-value pair from a property list, and get the individual key and value separately. However, I’m running into the following problem:

put the keys of parameters
put the keys of item 1 of parameters
put the keys of items (2,3) of parameters
put  items (2,3) of parameters
( ldapId:"mattstone", status:"Pass")

As you can see, I can get the keys of the entire parameter list, but not for a subset of the list

Any ideas?


Matt Stone

I think I have narrowed down this bug:

put item 1 of parameters

should be

put item 1 of parameters

put the keys of (buildId: “16100”)
put the values of (buildId: “16100”)

will work instead of

put the keys of (buildId: “16100”
in :
Syntax Error at line 1: Syntax Error - can’t understand “[end of script]” at or near character 34

The problem here is that you’re trying to treat a property list as a list. The name “property list” may be misleading in this case, as a property list is a fundamentally unordered collection of keys and values – so it’s not really a “list” which is an ordered collection of unlabeled values (I hope that’s clear!).

The keys() and values() functions will return ordered lists of either the keys or values of a property list, though, so you can extract a single key or value using something like the reverse of what you’re trying now – instead of “the keys of item 1”, try:

put item 1 of the keys of parameters

You can also get more than one:

put items 2 to 3 of the keys of parameters

I hope this helps make it more clear.