`deserialize(from:designatedPath:)`失败
- Dominant language
- Swift
- Stars
- 4.3k
- Forks
- 677
- PR merge metrics
- No merged PRs in 30d
Description
**解决方法:**
```swift
extension String: _BuiltInBasicType {
static func _transform(from object: Any) -> String? {
switch object {
case let str as String:
return str
case let num as NSNumber:
// Boolean Type Inside
if NSStringFromClass(type(of: num)) == "__NSCFBoolean" {
if num.boolValue {
return "true"
} else {
return "false"
}
}
return formatter.string(from: num)
case _ as NSNull:
return nil
case _ as NSObject:
do {
let data = try JSONSerialization.data(withJSONObject: object, options: .fragmentsAllowed)
return String(data: data, encoding: .utf8)
}catch {
fatalError(error.localizedDescription)
}
default:
fatalError("HandyJSON 数据解析失败,请检查数据格式!")
}
}
func _plainValue() -> Any? {
return self
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting `deserialize(from:designatedPath:)` and tracing how a JSON value is transformed into `String`. Compare its behavior with the supplied `String` extension, especially `NSNumber`, `NSNull`, and `NSObject` cases; done means the reported deserialization failure is resolved without requiring that workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100