This looks accurate, for formatting i’d probably do:
strings of values of entries whose (key of it = "name8") of dictionary of file "/Library/Preferences/exampleplist.plist"
I dont have access to a Mac but this may also work:
strings "name8" of dictionary of file "/Library/Preferences/exampleplist.plist"
These inspectors are very similar to the JSON and XML inspectors and it’s helpful to understand the original data format before trying to use the inspectors.
{
"Thing One" = {
Thing2 = {
"Thing Three" = (
"name one",
value1
);
"name two" = 1;
"name three" = 0;
};
"name four" = 4;
"name five" = five;
};
};
"name six" = "ess eye ex";
Thing4 = {
"name seven" = 7;
};
name8 = "eighth name";
thing9 = (
"name nine"
);
}
The root of the document is a dictionary
which is made up of dictionary entries
which each have a key
and a value
.
So:
{
name8 = "eighth name";
}
The outer { }
is how we know it’s a dictionary
. name8 = "eighth name"
is our dictionary entry
. name8 is our key
and “eighth name” is our value
.
So entries of dictionary of file "/Library/Preferences/exampleplist.plist"
would return a single dictionary entry
with a key
of “name8” and a value
of “eighth name”.
You might assume that value
is a string but it’s actually a value object
and to get the actual value out of it you need to tell us what type to get out of it which is what strings of <values>
does. If it was an integer we’d do integers of <values>
, etc.
So back to our original relevance:
strings of values of entries whose (key of it = "name8") of dictionary of file "/Library/Preferences/exampleplist.plist"
Broken down:
- Get the File:
file "/Library/Preferences/exampleplist.plist"
- Get the Dictionary:
dictionary of file "/Library/Preferences/exampleplist.plist"
- Get the Dictionary Entries:
entries of dictionary of file "/Library/Preferences/exampleplist.plist"
- Get the Dictionary Entries that match our criteria by adding
whose (key of it = "name8")
- Get the Value Object from the Dictionary Entry:
values of entries whose (key of it = "name8") of dictionary of file "/Library/Preferences/exampleplist.plist"
- Get a String from the Value Object:
strings of values of entries whose (key of it = "name8") of dictionary of file "/Library/Preferences/exampleplist.plist"
With this knowledge at hand you can re-use this logic to navigate into nested dictionaries:
- Get the
dictionary entries
nested inside of the top level “Thing One”: entries of entries whose (key of it = "Thing One") of dictionary of file "/Library/Preferences/exampleplist.plist"
- Get the nested Dictionary “Thing2”:
entries whose (key of it = "Thing2") of entries whose (key of it = "Thing One") of dictionary of file "/Library/Preferences/exampleplist.plist"
- Get the value of “name two” from the nested “Thing2” dictionary:
strings of values of entries whose (key of it = "name two") of entries whose (key of it = "Thing2") of entries whose (key of it = "Thing One") of dictionary of file "/Library/Preferences/exampleplist.plist"
If all of this traversal of entries is giving you a headache there are some helper properties available. The last example should be able to be simplified to:
strings "name two" of dictionary "Thing2" of dictionary "Thing One" of dictionary of file "/Library/Preferences/exampleplist.plist"
I haven’t actually tested these in QnA so there may be minor typos, etc. If you notice an error send me a PM so we can keep the thread here relatively clean!