Fix #116, json string misjudgment#119
Conversation
WalkthroughAdds a new test file with multiline JSON decoding tests and modifies String.toJSONObject() to remove a pre-check so JSONSerialization always attempts to parse the string. Changes
Sequence Diagram(s)sequenceDiagram
actor Test
participant TestTarget as Tests
participant Decoder as SmartCodable.decode
participant StringExt as String.toJSONObject()
participant JSONSer as JSONSerialization
Test->>TestTarget: run MultilineStringTest
TestTarget->>Decoder: decode(multilineString)
Decoder->>StringExt: toJSONObject()
note over StringExt: New flow — no early guard\nAlways attempt UTF-8 parse
StringExt->>JSONSer: parse(data)
alt Valid JSON
JSONSer-->>StringExt: JSONObject
StringExt-->>Decoder: JSONObject
Decoder-->>TestTarget: Decoded model/array
else Invalid JSON
JSONSer--x StringExt: parsing fails (try?)
StringExt-->>Decoder: nil
Decoder-->>TestTarget: nil / failed decode
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Example/Tests/MultilineStringTest.swift (2)
18-38: Test logic is solid; consider fixing the method name typo.The test correctly validates both valid multiline JSON parsing and nil handling for malformed input.
However, the method name appears to have a typo:
decodeMultilingDictStrshould likely bedecodeMultilineDict**Str**.Apply this diff to fix the typo:
- func decodeMultilingDictStr() { + func decodeMultilineDictStr() {
40-53: Array parsing test looks good; same typo in method name.The test properly validates multiline array parsing and type coercion from string to Int.
The method name has the same typo:
decodeMultilingArrayStrshould bedecodeMultilineArrayStr.Apply this diff to fix the typo:
- func decodeMultilingArrayStr() { + func decodeMultilineArrayStr() {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Example/Tests/MultilineStringTest.swift(1 hunks)Sources/SmartCodable/Core/JSONDecoder/Decoder/KeysMapper.swift(0 hunks)
💤 Files with no reviewable changes (1)
- Sources/SmartCodable/Core/JSONDecoder/Decoder/KeysMapper.swift
🔇 Additional comments (1)
Example/Tests/MultilineStringTest.swift (1)
12-15: LGTM!The test fixture is well-defined with appropriate default values for testing.
Summary by CodeRabbit
New Features
Bug Fixes
Tests