max max -5 years ago 153
JSON Question

Expecting value on the json.loads

in my app am calling a php script which will return a json encoded string

output = str(subprocess.check_output(["php","-f" , "../connector/somefile.php" ,"code_string:"+code_string]));

here is my print(output)


when i try to decode it into a dictionary

dic = json.loads(output)

i get

ValueError at /myapp/

Expecting value: line 1 column 1 (char 0)

whats wrong with this line ? isn't it a valid json ? i pretty sure im generating valid json object in the php file but i'm not sure what the extra
is in the begining of json string in the python side

Answer Source

'b stands for byte-string, if you decode it, it should work

{'code': 'pewcndIiD8WcB5MdH+8JOAVJ03xlt92sIUYgs2m2tIGtLohnDHjBP8s8x9/YroJnyrCLcyN6Brwicn9/DS4j9kH8a6gcOKFS1
bpmvdKxJSrmgT0aOz0u16npbt1ldklXx16WEybEN4gKG0DI=', 'success': '1'}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download