csgo crosshair generator v2
Category:Maps for Counter-StrikeAthletics at the 2013 Central American Games
The athletics competition at the 2013 Central American Games was held at the Estadio Olimpico Cézar Augusto Díaz in Guatemala City, Guatemala, between July 22-28. A total of 29 events were contested, 21 by men and 8 by women.
Participation
Total
Medal summary
Medal winners
Men
Women
Medal table
References
Results
Results
Results
Category:2013 Central American Games
2013
Central American GamesQ:
Python 2.7's built-in json module returns object when it should be dict
I'm using Python 2.7.9. I use the built-in json module to retrieve data. This data is like this:
{"1":{"age":20,"name":"John"}}
When I read it using the json module, I get this:
json.loads(data)
Is that normal? If it is, can I just replace '{' by '[' to get a list? I also try json.loads(data.replace('{','[')) but I get the following error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Please help.
A:
JSON is not Pythonic. It is a format that has been adopted for the express purpose of representing data, not for data modeling. You need to design a data model that fits your use case.
For example, a dictionary is the most natural way to represent the structure of your data. I'd write your example like this:
{"1":{"age":20,"name":"John"}}
import json
# data = {'1': {'age': 20, 'name': 'John'}}
data = json.loads('{"1":{"age":20,"name":"John"}}')
print(data['1']) # {'age': 20, 'name': 'John'}
As you can see, dictionaries are perfectly acceptable as a way to represent data. json does not care what type of data you are loading from it. It just loads the data. It is a "universal translator" that doesn't care be359ba680
Related links:
Comments