Passing php’s $_POST to a python script

As mentioned in the title, i am trying to pass the php $_POST array to a python script

I have the following php line:

echo shell_exec('python script.py ' . json_encode($_POST));

And this python code:

import sys
import json
import os.path

encodedinfo = sys.argv[1]
info = json.loads(encodedinfo);
print(info['id']);

i have found that the problem is with the json.loads() function, as if it is not commented the script does not reach the print() command.
How do i solve this?