Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ PODS:
- FBSnapshotTestCase/SwiftSupport (2.1.4):
- FBSnapshotTestCase/Core
- HandyJSON (5.0.0-beta.1)
- SmartCodable/Core (5.1.2)
- SmartCodable/Inherit (5.1.2):
- SmartCodable/Core (5.1.3)
- SmartCodable/Inherit (5.1.3):
- SmartCodable/Core
- SnapKit (5.6.0)

Expand Down Expand Up @@ -41,7 +41,7 @@ SPEC CHECKSUMS:
CleanJSON: 910a36465ce4829e264a902ccf6d1455fdd9f980
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
HandyJSON: 582477127ab3ab65bd2e471815f1a7b846856978
SmartCodable: 275755f95fd7019ce6b626f75517af5f2cf55bc7
SmartCodable: 45aa200d57f9f88eb48c0d2dcb555553ae9f8d44
SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25

PODFILE CHECKSUM: fbd909bd1bf3747400cd705163fad38954f6a18f
Expand Down
4 changes: 4 additions & 0 deletions Example/SmartCodable.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
99F9E8A62BB5139900D68037 /* MixDecodingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99F9E8A52BB5139900D68037 /* MixDecodingViewController.swift */; };
99FA1D502DF06B7D00560A05 /* DecodingLogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99FA1D4F2DF06B7D00560A05 /* DecodingLogViewController.swift */; };
AF374D4C62AA92DE0D9ED2B7 /* Pods_SmartCodable_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EB62463C4F6AEFEAA2A5E1E /* Pods_SmartCodable_Tests.framework */; };
DA0F36412E9BA4A10049EB49 /* MultilineStringTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA0F36402E9BA4A10049EB49 /* MultilineStringTest.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -292,6 +293,7 @@
AD8215B5E8E50F277C1C4356 /* Pods-SmartCodable_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartCodable_Example.release.xcconfig"; path = "Target Support Files/Pods-SmartCodable_Example/Pods-SmartCodable_Example.release.xcconfig"; sourceTree = "<group>"; };
AFEADC35BC2373F1DC69B73B /* Pods-SmartCodable_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartCodable_Tests.release.xcconfig"; path = "Target Support Files/Pods-SmartCodable_Tests/Pods-SmartCodable_Tests.release.xcconfig"; sourceTree = "<group>"; };
BC656B63C9031B22DEB5C8EB /* Pods-SmartCodable_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartCodable_Example.debug.xcconfig"; path = "Target Support Files/Pods-SmartCodable_Example/Pods-SmartCodable_Example.debug.xcconfig"; sourceTree = "<group>"; };
DA0F36402E9BA4A10049EB49 /* MultilineStringTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineStringTest.swift; sourceTree = "<group>"; };
DB7246035010143E03C7616B /* Pods-SmartCodable_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartCodable_Tests.debug.xcconfig"; path = "Target Support Files/Pods-SmartCodable_Tests/Pods-SmartCodable_Tests.debug.xcconfig"; sourceTree = "<group>"; };
EBE2539D7D4ED401A0AF07CA /* Pods_SmartCodable_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SmartCodable_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F415A4253833C1D4B5A35964 /* SmartCodable.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SmartCodable.podspec; path = ../SmartCodable.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
Expand Down Expand Up @@ -382,6 +384,7 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
DA0F36402E9BA4A10049EB49 /* MultilineStringTest.swift */,
99D17BB82B9F0CF9008ADAAB /* PerformanceTest.swift */,
99AE7D892B3EC02E00B474E5 /* Resource */,
607FACEB1AFB9204008FA782 /* Tests.swift */,
Expand Down Expand Up @@ -1132,6 +1135,7 @@
99D17BBA2B9F0CF9008ADAAB /* PerformanceTest.swift in Sources */,
99328D972B5138170074036A /* AreaTest.swift in Sources */,
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
DA0F36412E9BA4A10049EB49 /* MultilineStringTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
54 changes: 54 additions & 0 deletions Example/Tests/MultilineStringTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// MultilineStringTest.swift
// SmartCodable
//
// Created by Zero.D.Saber on 2025/10/11.
// Copyright © 2025 CocoaPods. All rights reserved.
//

import SmartCodable
import Testing

private struct User: SmartCodable {
var name: String = ""
var age: Int = 0
}

struct MultilineStringTest {
@Test(.bug("https://github.com/iAmMccc/SmartCodable/issues/116"))
func decodeMultilingDictStr() {
let jsonString1 = """
{
"name": "Sam",
"age": 22
}
"""
let user1 = User.deserialize(from: jsonString1)
#expect(user1?.name == "Sam")
#expect(user1?.age == 22)


let jsonString2 = """
"name": "Zero",
"age": 100

"""
let user2 = User.deserialize(from: jsonString2)
#expect(user2 == nil)
}

@Test("array case")
func decodeMultilingArrayStr() {
let jsonString = """
[
{
"name": "Zero",
"age": "99"
}
]
"""
let users = [User].deserialize(from: jsonString)
#expect(users?.first?.name == "Zero")
#expect(users?.first?.age == 99)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ extension Dictionary {

extension String {
func toJSONObject() -> Any? {
guard starts(with: "{") || starts(with: "[") else { return nil }
return data(using: .utf8).flatMap { try? JSONSerialization.jsonObject(with: $0) }
}
}