JSON data files have some odd list format #6

Open
opened 2025-10-02 02:10:20 +00:00 by omicron · 1 comment
Owner

The JSON data seems to emulate lists with dictionaries. It's not clear why we did it that way. Some of the data files actually use keys but others just have strings keys that are numbers "1" .. "n", perhaps it was just done this way to keep them all the same format.

The JSON data seems to emulate lists with dictionaries. It's not clear why we did it that way. Some of the data files actually use keys but others just have strings keys that are numbers `"1" .. "n"`, perhaps it was just done this way to keep them all the same format.
omicron added the
question
label 2025-10-02 02:10:20 +00:00
Author
Owner

For the uniques I have since figured out the reason. Unique items are indexed by their unique id, which is a sparse set of integers. Since json can only index in objects by strings this format makes sense. Haven't verified the others, but I assume the reason is similar.

>>> with open('d2warehouse/data/uniques.json') as f: uniques = json.load(f)
... 
>>> [i for i in range(407) if f"{i}" not in uniques]
[200, 247, 267, 278, 295, 303, 305, 318, 339, 346, 352, 362, 372, 377]
>>> 
For the uniques I have since figured out the reason. Unique items are indexed by their unique id, which is a sparse set of integers. Since json can only index in objects by strings this format makes sense. Haven't verified the others, but I assume the reason is similar. ``` >>> with open('d2warehouse/data/uniques.json') as f: uniques = json.load(f) ... >>> [i for i in range(407) if f"{i}" not in uniques] [200, 247, 267, 278, 295, 303, 305, 318, 339, 346, 352, 362, 372, 377] >>> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: omicron/d2warehouse#6
No description provided.