The code above is only an example.
The code does not search for global objects. To fix this, please add the following after line 17 -
This will also search in Global domain's database.
The parsing errors are due to the data in the responses from your database. For some reason, JQ tool fails to parse the data. The data is saved inside temporary files as noted at the top of the script (I suspect in package.json file). You may look at this data and verify the data inconsistency at the specified lines.
The "Requested object name [Network] is not unique" error is probably due to the fact that I use access-layer names instead of names+UIDs. If you have a global policy assigned in any of the domains, there may be two layers with a name 'Network'. To make this work, the code needs to save layer UID along with the layer name. A fix for this requires a bit more coding. I'll try to find some time and fix it later on.