videos = [[1,1,'url'],[1,2,'url'],[1,3,'url'],[2,1,'url'],[2,2,'url']]
[{
"1": {
"1": {"url"},
"2": { "url" },
"3": {"url"}
},
"2": {
"1": { "url" },
"2": { "url" }
}
}]
[{1: ['url']}, {3: ['url']}, {2: ['url']}, {1: ['url']}, {2: ['url']}]
{1: {'url'}, 2: {'url'}}
{"url"} - это не валидный json объект
import json
import collections
videos = [[1,1,'url'],[1,2,'url'],[1,3,'url'],[2,1,'url'],[2,2,'url']]
new = collections.defaultdict(dict)
for season, series, url in videos:
new[season][series] = url
print(json.dumps(new, indent=4))
{
"1": {
"1": "url",
"2": "url",
"3": "url"
},
"2": {
"1": "url",
"2": "url"
}
}