Skip to content

Commit 7126c92

Browse files
committed
Add frequently asked questions
1 parent 85e5e08 commit 7126c92

File tree

2 files changed

+58
-9
lines changed

2 files changed

+58
-9
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.1
1+
// swift-tools-version: 5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription

README.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Supports:
177177
• 01-01-2024
178178
• UNIX timestamp & with milisoconds: 1704067200 or 1704067200000
179179

180-
## 🔬 API
180+
## 🔬 More in depth
181181

182182
Accessors
183183

@@ -197,11 +197,60 @@ json.dictionary → [String: DynamicJSON]?
197197
json.isNull Bool
198198
```
199199

200-
## 🧪 Testing
201200

202-
Includes a full real-world test case covering:
203-
• All primitive types
204-
• Arrays and nested keys
205-
• Date strings and timestamps
206-
• Fuzzy and normalized keys
207-
• Null and missing key handling
201+
---
202+
203+
## 🎯 Frequently Asked Questions
204+
205+
### ❓ What happens if a key is missing?
206+
You’ll get `.null` back. You can check using `json["key"].isNull` or safely unwrap optional values.
207+
208+
---
209+
210+
### ❓ Will this crash if the JSON is malformed?
211+
No. If decoding fails, it throws like any regular `Decodable` type. Accessing values afterward will never crash — you’ll just get `nil` or `.null`.
212+
213+
---
214+
215+
### ❓ Does it work with nested objects and arrays?
216+
Yes. You can drill down using dot-paths (`json["user.settings.notifications"]`) or dynamic members (`json.user.settings.notifications`).
217+
218+
---
219+
220+
### ❓ Can I use it alongside regular `Codable` structs?
221+
Absolutely. Use `DynamicJSON` for dynamic/unknown parts of the payload, and `Codable` for strict parts.
222+
223+
---
224+
225+
### ❓ What date formats are supported?
226+
Out of the box:
227+
- ISO8601
228+
- RFC3339 with milliseconds
229+
- MySQL datetime (`yyyy-MM-dd HH:mm:ss`)
230+
- Short format (`yyyy-MM-dd`)
231+
- Timestamps in seconds and milliseconds
232+
233+
---
234+
235+
### ❓ How is it different from `[String: Any]`?
236+
Unlike `[String: Any]`, `DynamicJSON` is type-safe, supports dot access, fuzzy keys, smart casting, and works with Swift’s `Decodable`.
237+
238+
---
239+
240+
### ❓ Can I use this in production apps?
241+
Yes — it's designed to be resilient, readable, and production-safe.
242+
243+
---
244+
245+
### ❓ Will this impact performance?
246+
Key normalization and fuzzy matching are optimized and fast for typical payloads. If needed, you can disable fuzzy matching in future versions.
247+
248+
---
249+
250+
### ❓ What Swift versions are supported?
251+
Swift 5.9 and later (uses modern `Decodable` patterns and dynamic member lookup).
252+
253+
---
254+
255+
### ❓ Is this tested?
256+
Yes — it includes extensive tests for decoding, type coercion, fuzzy keys, date formats, and more.

0 commit comments

Comments
 (0)