26 lines
631 B
Python
26 lines
631 B
Python
import config
|
|
import json
|
|
|
|
def get_data(data_type, key='', value=''):
|
|
json_string = ''
|
|
match data_type:
|
|
case 'users':
|
|
json_string = open('data/users.json','r').read()
|
|
case 'menu':
|
|
json_string = open('data/menu.json','r').read()
|
|
case _:
|
|
json_string = ''
|
|
print('Error, invalid data type (data_management.get_data)')
|
|
|
|
json_data = json.loads(json_string)
|
|
if key != '':
|
|
for json_object in json_data:
|
|
if json_object[key] == value:
|
|
return json_object
|
|
else:
|
|
return json_data
|
|
|
|
return -1
|
|
|
|
|