我已经对json进行了硬编码
let json =
"""
{
"overview":"Miles Morales is juggling his life between being a high school student and being Spider-Man. However, when Wilson \"Kingpin\" Fisk uses a super collider, another Spider-Man from another dimension, Peter Parker, accidentally winds up in Miles' dimension. As Peter trains Miles to become a better Spider-Man, they are soon joined by four other Spider-Men from across the \"Spider-Verse\". As all these clashing dimensions start to tear Brooklyn apart, Miles must help the others stop Fisk and return everyone to their own dimensions."
}
"""
和一个结构
struct A: Codable {
var overview: String
}
当我使用JsonDecoder对其进行解码时,它会引发错误
let data = json.data(using: .utf8)!
let apiResponse = try JSONDecoder().decode(A.self, from: data)
DecodingError
▿ dataCorrupted : Context
- codingPath : 0 elements
- debugDescription : "The given data was not valid JSON."
▿ underlyingError : Optional<Error>
- some : Error Domain=NSCocoaErrorDomain Code=3840 "Badly formed object around character 129." UserInfo={NSDebugDescription=Badly formed object around character 129.}
发生此错误是因为json中的\“。我尝试了所有操作以删除\”,但每次都失败。
有人可以在这里帮助我吗?