import json | |
# Load JSON file | |
with open('s_app_s_step.json', 'r', encoding='utf-8') as file: | |
data = json.load(file) | |
# Extract all query values and join them with newlines | |
query_list = [] | |
for entry in data: | |
queries = entry.get('query', []) | |
for query in queries: | |
# Ensure each query is a string | |
if isinstance(query, dict): | |
query_list.append(json.dumps(query, ensure_ascii=False)) # Convert dict to JSON string if needed | |
else: | |
query_list.append(query) | |
# Join queries with newline separator | |
all_queries = '\n'.join(query_list) | |
# Write to a new file | |
with open('all_queries.txt', 'w', encoding='utf-8') as output_file: | |
output_file.write(all_queries) | |
print("All queries have been saved to all_queries.txt") | |