python client reading json list from python server
Question: I know there are many json tutorials and Q&A here and on the net, which I've
read; but I'm still struggling to get my python script working.

I'm calling a python server program from a client to read a sample list. My
error is:

    
    
    <type 'exceptions.ValueError'>: No JSON object could be decoded
     args = ('No JSON object could be decoded',)
     message = 'No JSON object could be decoded'
    

Somewhere in the server I've got the wrong code, which is not taking the list
and sending it as a json string.

I'm running everything on a Mongoose webserver.

Server (psptest5.py):

    
    
    #!C:\Mongoose\Python26\python.exe
    
    import cgi
    import cgitb
    cgitb.enable()
    import pyodbc
    import json
    import urllib2
    import requests
    
    url = "http://localhost:8080/"
    value= {'customer' : 'Varun Inc','email' : 'varun.verma@varun.com'}
    
    headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
    r = requests.post(url, data=json.dumps(value), headers=headers)
    

Client(jsonreadtest.py):

    
    
    #!C:\Mongoose\Python26\python.exe
    
    import cgi
    import cgitb
    cgitb.enable()
    import json
    import urllib2
    from pprint import pprint
    import csv, sys
    
    url = 'http://localhost:8080/psptest5.py'
    data = json.load(urllib2.urlopen(url))
    print data
    

Any help appreciated


Answer: Your server doesn't seem to be actually _returning_ anything, so when your
client runs `data = json.load(urllib2.urlopen(url))` it's trying to load JSON
from an empty string.

