Take the 2-minute tour ×

I'm having some trouble decoding this json in python.

From basehttpserver I'm getting back

    "changed_aspect": "media", 
    "object": "geography", 
    "object_id": "1306", 
    "subscription_id": 1326, 
    "time": 1300570688

which I'm putting into simplejsondecoder with

data = simplejson.loads(s)

but when I look at the length of data it's coming back with 1, not 5 for the json objects like I'm expecting.

Here's all of the code, incase the problem lies elsewhere.

class httpserver(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_POST(self):
        self.data_string = self.rfile.read(int(self.headers['Content-Length']))

        data = simplejson.loads(self.data_string)
        print len(data)
share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

When you decode the JSON you get exactly what it looks like, a list containing a single item.

data[0] should be the dictionary you expected to see.

share|improve this answer
Well, I feel dumb. Thanks Andrew! –  exiva Mar 19 '11 at 22:03
add comment

Your Answer


