0

I am using the "requests" module in order to get the content of a web page which happens to be a JSON file. What I want is to convert this JSON to a Python's dictionary.

Here is the code I am using so far:

import requests
import json


apiURL = "http://www.cryptocompare.com/api/data/coinlist/"
content = requests.get(apiURL)
content = r.content
content = json.load(r)

While I am expecting the created dictionary to contains the whole JSON from the beggining till the end as shown in the image below:
enter image description here

The created dictionary starts from the middle or in another words doesn't contains the first lines of the JSON. enter image description here

Why is this happening and how can I fix that?

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
Theof
  • 83
  • 1
  • 7
  • 1
    maybe try using OrderedDict instead if order matters to you: https://docs.python.org/2/library/collections.html#ordereddict-objects – deweyredman Jan 04 '17 at 21:31
  • In the JSON format the type object is considered unordered already, very similar to Python dictionaries. You can not rely on the order at any time in both languages. – Klaus D. Jan 04 '17 at 22:18
  • What I want to do is to create a dictionary exactly like the JSON file. It's not about ordering with a specific way. – Theof Jan 05 '17 at 14:23

0 Answers0