|
@@ -19,20 +19,24 @@ error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjisuv/errorBag.json
|
|
|
|
|
|
def parse_json_to_string_array(file_path):
|
|
|
try:
|
|
|
-
|
|
|
- with open(file_path, 'r', encoding='utf-8') as file:
|
|
|
-
|
|
|
- data = json.load(file)
|
|
|
+
|
|
|
+ with open(file_path, 'r') as file:
|
|
|
+
|
|
|
+ file_content = file.read()
|
|
|
+
|
|
|
+ data = json.loads(file_content.decode('utf-8'))
|
|
|
|
|
|
|
|
|
if isinstance(data, list):
|
|
|
for item in data:
|
|
|
- if not isinstance(item, str):
|
|
|
+ if not isinstance(item, basestring):
|
|
|
raise ValueError("JSON数组中的元素不是字符串")
|
|
|
return data
|
|
|
else:
|
|
|
return []
|
|
|
except Exception as e:
|
|
|
+
|
|
|
+
|
|
|
return []
|
|
|
|
|
|
|
|
@@ -45,13 +49,14 @@ def list_to_json_file(data, file_path):
|
|
|
data (list): 要转换为JSON的列表。
|
|
|
file_path (str): 要写入JSON数据的文件路径。
|
|
|
"""
|
|
|
-
|
|
|
+
|
|
|
json_data = json.dumps(data, ensure_ascii=False, indent=4)
|
|
|
+ json_data_utf8 = json_data.encode('utf-8')
|
|
|
|
|
|
|
|
|
- with open(file_path, 'w', encoding='utf-8') as file:
|
|
|
-
|
|
|
- file.write(json_data)
|
|
|
+ with open(file_path, 'w') as file:
|
|
|
+
|
|
|
+ file.write(json_data_utf8)
|
|
|
|
|
|
|
|
|
def generate_xosc(parse_prefix, local_parse_dir, local_delete_list):
|