// Posts#json
Cách Transform JSON Data để Khớp Bất Kỳ Schema Nào - Pure Python vs Pandas
#9732026-05-06

Cách Transform JSON Data để Khớp Bất Kỳ Schema Nào - Pure Python vs Pandas

pandas.json_normalize() trong pandas 3.0 tự động flatten nested dict thành dot-separated columns, mở rộng list thành từng row qua record_path. Tham số errors='ignore' ngăn crash khi schema API không nhất quán - nhưng phải kiểm tra lại bằng df.isna().sum(). Custom Python .get() nhanh hơn 3-5x khi chỉ cần 2-3 field từ JSON sâu nhiều cấp. jsonschema library giúp validate output đúng schema trước khi import hoặc forward đến API tiếp theo.

pythonjsonpandas
6 phút đọc