
Python
Work with large JSON files and custom data type serialization.
import ijson
# Parse large JSON files without loading all into memory
with open("huge.json", "rb") as f:
for item in ijson.items(f, "items.item"):
process(item) # Process items one at a timeimport json
from datetime import datetime
class CustomEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime):
return obj.isoformat()
return super().default(obj)
# Serialize custom objects
data = {"timestamp": datetime.now()}
json_str = json.dumps(data, cls=CustomEncoder)
# Custom decoder
def custom_decoder(dct):
if "timestamp" in dct:
dct["timestamp"] = datetime.fromisoformat(dct["timestamp"])
return dct
loaded = json.loads(json_str, object_hook=custom_decoder)Ready to practice? Challenges | Quiz
Resources
Ojasa Mirai
Master AI-powered development skills through structured learning, real projects, and verified credentials. Whether you're upskilling your team or launching your career, we deliver the skills companies actually need.
Learn Deep • Build Real • Verify Skills • Launch Forward