<< All versions
Skill v1.0.0
currentAutomated scan93/100everfern-ai/everfern/json
──Details
PublishedOctober 25, 2026 at 07:38 PM
Content Hashsha256:bd8e7dc748e9d782...
Git SHA75558f731fb1
──Files
Files (1 file, 5.3 KB)
SKILL.md5.3 KBactive
SKILL.md · 243 lines · 5.3 KB
version: "1.0.0" name: json description: "Use this skill any time a JSON (JavaScript Object Notation) file is the primary input or output. This includes tasks to: read, parse, validate, analyze, or modify JSON files; create new JSON files; merge or transform JSON structures; extract data from JSON; convert data to JSON format. If the user mentions a JSON file by name, extension, or path (.json), use this skill."
JSON File Handling in EverFern
Overview
Users may ask you to read, analyze, create, or modify JSON files. Use Python with built-in json module or pandas for structured data. Use absolute Windows paths (e.g., C:\Users\Username\Downloads\data.json).
Reading JSON Files
Read and Parse JSON
python
import json# Read JSON filewith open(r'C:\path\to\file.json', 'r') as f:data = json.load(f)# Print formatted JSONprint(json.dumps(data, indent=2))# Get specific valuesvalue = data['key']nested_value = data['parent']['child']
Read with pandas (for tabular JSON)
python
import pandas as pd# Read JSON file as DataFramedf = pd.read_json(r'C:\path\to\file.json')# Preview dataprint(df.head())print(df.info())
Writing JSON Files
Write Python Objects as JSON
python
import jsondata = {'name': 'John','age': 30,'email': 'john@example.com','hobbies': ['reading', 'coding', 'gaming']}# Write to file (formatted)with open(r'C:\path\to\output.json', 'w') as f:json.dump(data, f, indent=2)# Write minified (compact)with open(r'C:\path\to\output_minified.json', 'w') as f:json.dump(data, f)
Parsing and Transforming JSON
Parse JSON String
python
import jsonjson_string = '{"name": "Alice", "age": 25}'data = json.loads(json_string) # Parse stringprint(data['name'])
Convert JSON to String
python
json_string = json.dumps(data, indent=2)print(json_string)
Validate JSON
python
import jsondef validate_json(json_file):try:with open(json_file, 'r') as f:json.load(f)print("✓ Valid JSON")return Trueexcept json.JSONDecodeError as e:print(f"✗ Invalid JSON: {e}")return Falsevalidate_json(r'C:\path\to\file.json')
Data Transformation
Extract and Transform Data
python
import json# Read JSONwith open(r'C:\path\to\input.json', 'r') as f:data = json.load(f)# Transform (example: extract specific fields)transformed = [{'id': item['id'], 'name': item['name']}for item in data]# Write transformed datawith open(r'C:\path\to\output.json', 'w') as f:json.dump(transformed, f, indent=2)
Flatten Nested JSON
python
import jsonimport pandas as pdwith open(r'C:\path\to\nested.json', 'r') as f:data = json.load(f)# Flatten to DataFrame then back to JSONdf = pd.json_normalize(data)flattened = json.loads(df.to_json(orient='records'))with open(r'C:\path\to\flattened.json', 'w') as f:json.dump(flattened, f, indent=2)
Merge Multiple JSON Files
python
import jsonfiles = [r'C:\path\to\file1.json',r'C:\path\to\file2.json',r'C:\path\to\file3.json']merged = []for file in files:with open(file, 'r') as f:merged.extend(json.load(f))with open(r'C:\path\to\merged.json', 'w') as f:json.dump(merged, f, indent=2)
Query and Filter JSON
Filter Arrays in JSON
python
import jsonwith open(r'C:\path\to\file.json', 'r') as f:data = json.load(f)# Filter: get items where age > 25filtered = [item for item in data if item['age'] > 25]with open(r'C:\path\to\filtered.json', 'w') as f:json.dump(filtered, f, indent=2)
Group JSON Data
python
import jsonfrom itertools import groupbywith open(r'C:\path\to\file.json', 'r') as f:data = json.load(f)# Group by categorygrouped = {}for item in data:category = item['category']if category not in grouped:grouped[category] = []grouped[category].append(item)with open(r'C:\path\to\grouped.json', 'w') as f:json.dump(grouped, f, indent=2)
Special Cases
Handle Large JSON Files
python
import json# Process in chunksdef process_large_json(file_path, chunk_size=1000):with open(file_path, 'r') as f:data = json.load(f)for i in range(0, len(data), chunk_size):chunk = data[i:i + chunk_size]# Process chunkprint(f"Processing {len(chunk)} items...")# Save chunk resultswith open(f'output_{i}.json', 'w') as out:json.dump(chunk, out)process_large_json(r'C:\path\to\large_file.json')
Add UTF-8 BOM (for Excel compatibility)
python
import jsonwith open(r'C:\path\to\file.json', 'w', encoding='utf-8-sig') as f:json.dump(data, f, indent=2, ensure_ascii=False)
Tips and Best Practices
- Always validate: Use
try/exceptwithjson.JSONDecodeErrorwhen reading untrusted JSON - Pretty print: Use
indent=2orindent=4for human-readable output - Encoding: Always specify
encoding='utf-8'for Windows compatibility - Escape characters: Use
ensure_ascii=Falseto preserve non-ASCII characters - Large files: For very large JSON, consider streaming or chunking
- Comments: JSON doesn't support comments; use separate
.jsoncfiles if comments are needed