I'm trying to write a plist from a bash script that has multiple nested dictionaries (dictionary within a dictionary within an array for example).
Right now I'm using the defaults command, which works for normal keys and dictionaries/arrays, but doesn't seem to have support for nested dictionaries/arrays. I need the script to run independently on any mac, so I can't use third party tools that don't come preinstalled on MacOS.
The structure I want to achieve is similar to this image.
It's not well known (I only discovered it recently), but
plutil is able to add or insert various values into plist, including adding arrays and entries to those. Here's a page that discusses using it that might help: https://scriptingosx.com/2016/11/editing-property-lists/
They even suggest that it's a good potential replacement to PlistBuddy.
Edit: Just wanted to add that
plutil also may not be cfprefsd aware, so it could require restarting
cfprefsd to get the altered values read in.