As per the documentation
The RFC specifies that the names within a JSON object should be unique, but does not mandate how repeated names in JSON objects should be handled. By default, this module does not raise an exception; instead, it ignores all but the last name-value pair for a given name:
>>> weird_json = '{"x": 1, "x": 2, "x": 3}'
>>> json.loads(weird_json)
{'x': 3}
The object_pairs_hook parameter can be used to alter this behavior.
Documentation also state that object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also defined, the object_pairs_hook takes priority.
For example,
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from collections import defaultdict
>>> from pprint import pprint
>>>
>>> s = """
... {
... "http":{
... "http://":"64.90.50.38:45876/",
... "http://":"89.250.220.40:54687/",
... "http://":"89.207.92.146:37766/",
... "http://":"89.23.194.174:8080/",
... "http://":"82.208.111.100:52480/"
... }
... }
... """
>>>
>>> def custom_hook(obj):
... # Identify dictionary with duplicate keys...
... # If found create a separate dict with single key and val and as list.
... if len(obj) != len(set(i for i, j in obj)):
... data_dict = defaultdict(list)
... for i, j in obj:
... data_dict[i].append(j)
... return dict(data_dict)
... return dict(obj)
...
>>> data = json.loads(s, object_pairs_hook=custom_hook)
>>> pprint(data)
{'http': {'http://': ['64.90.50.38:45876/',
'89.250.220.40:54687/',
'89.207.92.146:37766/',
'89.23.194.174:8080/',
'82.208.111.100:52480/']}}
>>>
>>> pprint(data['http'])
{'http://': ['64.90.50.38:45876/',
'89.250.220.40:54687/',
'89.207.92.146:37766/',
'89.23.194.174:8080/',
'82.208.111.100:52480/']}