doc
consists of just plain Python builtin types. You're not really querying anything.
That line that isn't working is trying to format the result of doc['RealBank']['Players']['%s']['Balance']
, with %s
being the literal key name. If you want to use bean
as a key, then just pass in the variable:
print doc['RealBank']['Players'][bean]['Balance']
You could also use .items()
to iterate over key, value tuples:
for name, player in doc['RealBank']['Players'].items():
print name, player['Balance']