Analyzing JSON data from a html source in python

advertisements

I have a bunch of data that looks like this:

{"Game":"Chess","title":"just for fun!","size":"2","entriesData":["PLAYERNAME","IMAGEHERE"],"entryFee":1,"prizeSummary","gameId":"9436","tableSpecId":"1079","dateUpdated":1389810809648,"dateCreated":1389659697294,"stack":235,"entryHTML":null}

with basically a bunch of entries one after another.

I want to parse this data to get playername, game type, etc.

I know I should use the JSON library to accomplish this.

The page I get the code from has a bunch of HTML on it as well. Is it okay to use the json.load on the html, or should I strip that from it first?

I'm not really entirely sure where to begin solving this problem, and am a bit confused by the JSON documentation.

Any tips or hints would be greatly appreciated.


jsonDictionaryRepresentation = json.loads(yourJsonObject)

then operate on it as a dictionary. Implicit in json.loads is that it is in fact valid json so yes, if the payload you are getting has a response body that includes something other than json, you'd have to strip that out.