Skip to content
intsig171 edited this page Apr 3, 2025 · 2 revisions

SmartCodable

SmartCodable - Ultimate Codable Enhancement for Swift

SmartCodable redefines Swift data parsing by augmenting Apple's native Codable with production-ready resilience and flexibility. Where standard Codable fails on real-world data, SmartCodable delivers bulletproof parsing with minimal boilerplate.

SmartCodable vs Codable

Feature Category English Description
Error Tolerance Military-grade handling of type mismatches, null values, and missing keys
Type Adaptation Automatic bidirectional type conversion (String⇄Number, Number⇄Bool, etc.)
Default Value Fallback Falls back to property initializers when parsing fails
Key Mapping Multi-source key mapping with priority system
Value Transformation Custom value transformers
Collection Safety Safe collection handling (empty arrays→nil, invalid elements→filtered)
Deep Modelization Recursive modelization of nested JSON structures
Dynamic Types Full support for Any, [Any], [String:Any] via @SmartAny
Naming Strategies Global key strategies (snake_case⇄camelCase, capitalization)
Lifecycle Hooks didFinishMapping() callback for post-processing
Incremental Updates Partial model updates without full re-parsing
Property Wrappers such as@IgnoredKey, @SmartFlat,@SmartAny
Debugging Support Built-in logging with path tracing for decoding errors
Path Navigation Deep JSON access using dot notation (designatedPath: "data.user")
PropertyList Support Native support for parsing PropertyList data without JSON conversion
Parsing Diagnostics Real-time monitoring with SmartSentinel.monitorLogs()

SmartCodable vs HandyJSON

🎯 Feature 💬 Description SmartCodable HandyJSON
Strong Compatibility Perfectly handles: Missing fields & Null values & Type mismatches ✅ ✅
Type Adaptation Automatic conversion between types (e.g., JSON Int to Model String) ✅ ✅
Any Parsing Supports parsing [Any], [String: Any] types ✅ ✅
Decoding Callback Provides didFinishingMapping callback when model decoding completes ✅ ✅
Default Value Initialization Uses property's initial value when parsing fails ✅ ✅
String-to-Model Parsing Supports parsing JSON strings into models ✅ ✅
Enum Parsing Provides fallback for failed enum parsing ✅ ✅
Custom Property Parsing - Renaming Custom decoding keys (renaming model properties) ✅ ✅
Custom Property Parsing - Ignoring Ignores specific model properties during decoding ✅ ✅
designatedPath Support Custom parsing paths ✅ ✅
Model Inheritance Codable has weaker support for inheritance (possible but inconvenient) ❌ ✅
Custom Parsing Paths Specifies starting JSON hierarchy level for parsing ✅ ✅
Complex Data Decoding Advanced data processing during decoding (e.g., data flattening) ✅ ⚠️
Decoding Performance SmartCodable averages 30% better performance ✅ ⚠️
Error Logging Provides troubleshooting logs for compatibility handling ✅ ❌
Security Implementation stability and security ✅ ❌

If you are using HandyJSON and would like to replace it, follow this link.

👉 SmartCodable - Compare With HandyJSON

Key Advantages:

  • 30% better performance
  • More stable and secure implementation
  • Built-in error diagnostics
  • Superior complex data handling

SmartCodable Supported Types Comparison

Type Examples
Integer Int, Int8-64, UInt, UInt8-64
Floating Point Float, Double, CGFloat
Boolean Bool (accepts true/1/"true")
String String (auto-converts from numbers)
Foundation URL, Date, Data, UIColor
Enums All RawRepresentable enums
Collections [String: Codable], [Codable]
Nested Models Any Codable custom types
Wrappers @SmartAny, @IgnoredKey, etc.

Clone this wiki locally