Replaced json with ujson

This commit is contained in:
Profitroll 2023-04-23 10:44:21 +02:00
parent 4ce4cb1a47
commit e3e6d34677
2 changed files with 5 additions and 8 deletions

View File

@ -1,16 +1,14 @@
import asyncio import asyncio
from datetime import datetime from datetime import datetime
from random import choice from random import choice
import time
import traceback import traceback
from typing import List from typing import List
import discord, json # type: ignore import discord, ujson
import os import os
from modules.booruGet import booruGet from modules.booruGet import booruGet
from discord import Embed, ButtonStyle, ApplicationContext, Option # type: ignore from discord import Embed, ButtonStyle, ApplicationContext, Option # type: ignore
from discord.enums import ChannelType # type: ignore
#from discord_slash import SlashCommand, SlashContext #from discord_slash import SlashCommand, SlashContext
@ -26,13 +24,11 @@ def logWrite(message):
def jsonSave(filename, value): def jsonSave(filename, value):
with open(filename, 'w', encoding="utf-8") as f: with open(filename, 'w', encoding="utf-8") as f:
json.dump(value, f, indent=4, ensure_ascii=False) f.write(ujson.dumps(value, indent=4, ensure_ascii=False))
f.close()
def jsonLoad(filename): def jsonLoad(filename):
with open(filename, 'r', encoding="utf-8") as f: with open(filename, 'r', encoding="utf-8") as f:
value = json.load(f) value = ujson.loads(f.read())
f.close()
return value return value
#========================================================================================================================= #=========================================================================================================================

View File

@ -1,2 +1,3 @@
py-cord[speed]==2.4.1 py-cord[speed]==2.4.1
requests==2.28.2 requests==2.28.2
ujson==5.7.0