20250904-初步功能已完成
This commit is contained in:
@@ -179,17 +179,31 @@ class JsonUtils:
|
||||
|
||||
return updated
|
||||
|
||||
# @classmethod
|
||||
# def query_all_json_items(cls, filename="log/last_message.json") -> list:
|
||||
# """
|
||||
# 查询 JSON 文件(数组)中的所有项
|
||||
# :param filename: JSON 文件路径
|
||||
# :return: list,可能为空
|
||||
# """
|
||||
# file_path = Path(filename)
|
||||
# print(file_path)
|
||||
# data = cls._read_json_list(file_path)
|
||||
# return data if isinstance(data, list) else []
|
||||
|
||||
@classmethod
|
||||
def query_all_json_items(cls, filename="log/last_message.json") -> list:
|
||||
"""
|
||||
查询 JSON 文件(数组)中的所有项
|
||||
查询 JSON 文件(数组)中的所有项,并剔除 sender 为空的记录
|
||||
:param filename: JSON 文件路径
|
||||
:return: list,可能为空
|
||||
"""
|
||||
file_path = Path(filename)
|
||||
print(file_path)
|
||||
data = cls._read_json_list(file_path)
|
||||
return data if isinstance(data, list) else []
|
||||
if not isinstance(data, list):
|
||||
return []
|
||||
# 过滤 sender 为空字符串的项
|
||||
return [item for item in data if isinstance(item, dict) and item.get("sender", "").strip()]
|
||||
|
||||
@classmethod
|
||||
def delete_json_items(cls,
|
||||
|
||||
Reference in New Issue
Block a user