I suck ass at python, I should get better at it but the lib im using is all in python. I am getting a huge json string in a response, I would like to parse it nicely. I also don’t want to spend an hour reading about parsing json in python (since like I said, suck ass with it, so be patient)
it’s sensitive data so sorry if its cryptic (its not all my data), here is some of it I guess
I’m taking all suggestions. I already tried importing json and using json.load but got a gay python error, like this one…
File "example.py", line 14, in <module>
json.load(getMsgs)
File "/usr/lib/python2.7/json/__init__.py", line 287, in load
return loads(fp.read(),
AttributeError: 'dict' object has no attribute 'read'
it’s not imperative, i’ll figure it out but I thought you guys might be able to steer me somewhere helpful or give me the instant gratification we all want when we’re coding.
sorry but I used to live by michael jordan… lol i saw your icon, he was awesome… anyway…
there is like A LOT of json and its a bunch of records, so just splitting it wont work for me (im pretty proficient in tons of langs ) i really do need like a php version of json_decode to prettify or at least give… idk, the json from this is weird lookin to me
by the way , after this problem what i recommend is to use the json library in python you can load a json code and parse it using the library for the full read , visit https://docs.python.org/2/library/json.html
Ah, no wonder the json looked funny, I was wondering why it had the single quote and a ‘u’. Also, is my library messed up or am I not doing it right, I keep getting the loads error
Traceback (most recent call last):
File "example.py", line 13, in <module>
msgs = json.loads(TN.getMessages())
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
also, in python, if the def arguments are already defined do I still need to put it in the call? here is the function def
If the function is already defined, you don’t use def in the call.
Now about your loads error, are you sure you’re not trying to load a file object or iterator something that’s not a string? loads expects a plain old string with json in it.