How to pass a JSON string to shell_exec() without losing the double quotes?

I use a RUN Button in a grid application to extract data from the DB and pass it on to the shell as a JSON string.

I have generated a JSON string from a PHP associative array like so:

$record = ('rec_num' => "001034", 'name' => "Paul Smith");
$jstr = json_encode($record);

I want to pass it on to a Python script for processing using the shell_exec() function. I can’t find a way to pass the string without losing the double quotes around the arrays KEY: VALUE pairs. Being a novice, I have hacked my way through the solution, and I am too ashamed to post my hack. :blush:

Is there a proper way to do this?

I have come across posts on StackOverflow suggesting that I have to add an HTML header to the code as such:

header('Content-Type: application/json');

Where could I add such a header?