21 lines
683 B
Python
21 lines
683 B
Python
import json
|
|
|
|
|
|
class numeric:
|
|
def __init__(self, file_path:str, type:int):
|
|
self.indexed_data = {}
|
|
with open(file_path, "rt", encoding="utf-8") as f:
|
|
if type == 0:
|
|
values = json.load(f)["Data"]
|
|
for value in values:
|
|
self.indexed_data[value["sn"]] = value
|
|
if type == 1:
|
|
values = json.load(f)
|
|
for i in range(0, len(values["IDs"])):
|
|
id = values["IDs"][i]
|
|
self.indexed_data[id] = values["Data"][i]
|
|
|
|
def get(self, id):
|
|
if id not in self.indexed_data:
|
|
return None
|
|
return self.indexed_data[id] |