I am looking use PowerShell to output some JSON that looks like this for use with a Python script:

> 
> 
> ```
>  {
> "run_date": "2020-08-27",
> "total_queries": 4,
> "number_results": 3,
> "number_warnings": 1,
> "number_errors": 5,
> "build_url": "https://some-url.com",
> "queries":{
>     "query_a":{
>         "database_a": "102 rows",
>         "database_b": "Error: See pipeline logs for details"
>     },
>     "query_b": "No results",
>     "query_c": {
>         "database_a": "Warning: Number of results exceeded maximum threshold - 6509 rows",
>         "database_c": "Error: See pipeline logs for details",
>         "database_d": "Error: See pipeline logs for details"
>     }
> } }
> 
> ```
> 
> 

(Ignore the above closing bracket, it won't format properly on here for some reason).

I am using a foreach loop within PowerShell to run each of these queries sequentially depending on which databases they need to be ran on.

I know in Python I can create a template of the JSON like so:

> 
> 
> ```
> options = {
> 'run_date': os.environ['SYSTEM_PIPELINESTARTTIME'].split()[0],
> 'total_queries': 0,
> 'number_results': 0,
> 'number_warnings': 0,
> 'number_errors': 0,
> 'build_url': 'options = {
> 'run_date': os.environ['SYSTEM_PIPELINESTARTTIME'].split()[0],
> 'total_hunts': 0,
> 'number_results': 0,
> 'number_warnings': 0,
> 'number_errors': 0,
> 'build_url': 'https://some-url.com',
> 'queries': {} }
> 
> ```
> 
> 

and then use something like:

> 
> options['queries'][filename][database] = '{} rows'.format(len(data))
> 
> 
> 

To add data into the Python dictionaries.

I've tried using nested PSCustomObjects but I end up with a conflict when different queries are being ran on the same database, so its trying to add a value to the PSCustomObject with the same Key. I would like to know if there is a nice 'native' way to do this in PowerShell like there is in Python.