You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to nest dictionary in dictionary and array in dictionary

This may be a dumb question but I can't figure out how to put a dictionary in a dictionary and then nest an array in a dictionary in custom settings. I am attempting to set java plugin settings for safari and I can't figure out how to nest items in each other.
Thanks.

Posted on Jul 16, 2014 11:49 AM

Reply
2 replies

Jul 16, 2014 12:41 PM in response to lilchub101

You have to make friends with PlistBuddy. The defaults command is not enough. See man PlistBuddy for details. And yes, case is important here. Oh, and you need to path to the tool like /usr/libexec/PlistBuddy. Here is an example, used to modify Time Machines backup Interval:

/usr/libexec/PlistBuddy -c "Set :LaunchEvents:com.apple.xpc.activity:com.apple.backupd-auto:Interval 21600" /System/Library/LaunchDaemons/com.apple.backupd-auto.plist

Please note that if the keys do not exist, you will likely need to string, multiple PlistBuddy commands together, mixing the Add and Set verbs.

Reid

Apple Consultants Network

Apple Professional Services

Author "Mavericks Server – Foundation Services" :: Exclusively available in Apple's iBooks Store

Jul 17, 2014 3:51 AM in response to lilchub101

The defaults command is in general an excellent tool and has one unique advantage (more later) but is pretty much useless when dealing with arrays (as said by Stronium90). For arrays plistbuddy is the way to go.


The unique advantage of defaults over plistbuddy is that when you make a change to a plist file using defaults this is automatically flushed from any cache meaning any software relying on that plist you are modifying gets to see the updates straight away. With plistbuddy the changes while saved might not be read by applications using the plist because of the caching.


A possible way round this would be to make the change using plistbuddy and then after doing so follow this up by doing a


defaults read com.yourcompany.yourfile


(If you don't specify a particular key it reads the whole file.)

How to nest dictionary in dictionary and array in dictionary

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.