I get this string from stdin.
{u'trades': [Custom(time=1418854520, sn=47998, timestamp=1418854517, price=322, amount=0.269664, tid=48106793, type=u'ask', start=1418847319, end=1418847320), Custom(time=1418854520, sn=47997, timestamp=1418854517, price=322, amount=0.1, tid=48106794, type=u'ask', start=1418847319, end=1418847320), Custom(time=1418854520, sn=47996, timestamp=1418854517, price=321.596, amount=0.011, tid=48106795, type=u'ask', start=1418847319, end=1418847320)]}
My program fails when i try to access jsonload["trades"]
. If i use jsonload[0]
I only receive one character: {
.
I checked it isn't a problem from get the text from stdin
, but I don't know if it is a problem of format received (because i used Incursion library) or if it is a problem in my python code. I have tried many combinations about json.load/s
and json.dump/s
but without success.
inputdata = sys.stdin.read()
jsondump = json.dumps(inputdata)
jsonload = json.loads(jsondump)
print jsonload
print type(jsonload) # return me "<type 'unicode'>"
print repr(jsonload) # return me same but with u" ..same string.... "
for row in jsonload["trades"]: # error here: TypeError: string indices must be integers