Avatar
Avatar
Iceman
@swift-5.5.3 import Foundation let json = """ { "foo": "{\"key\": \"value\"}" } """.data(using: .utf8)! struct Body: Codable { var foo: String } let decoder = JSONDecoder() let decoded = try decoder.decode(Body.self, from: json) print(decoded) (edited)
exit status: 132 with stderr:Swift/ErrorType.swift:200: Fatal error: Error raised at top level: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Foundation.JSONError.unexpectedCharacter(ascii: 107, characterIndex: 16)))) Current stack trace: 0 libswiftCore.so 0x00007f8a2e843cd0 swift_reportError + 50 1 libswiftCore.so 0x00007f8a2e8bc2a0 _swift_stdlib_reportFatalErrorInFile + 109 2 libswiftCore.so 0x00007f8a2e5c95a2 <unavailable> + 1414562 3 libswiftCore.so 0x00007f8a2e5c92cb <unavailable> + 1413835 4 libswiftCore.so 0x00007f8a2e5c7fb0 _assertionFailure(_:_:file:line:flags:) + 447 5 libswiftCore.so 0x00007f8a2e628d10 swift_errorInMain + 731 7 swift-frontend 0x00000000006e228a <unavailable> + 3023498 8 swift-frontend 0x00000000005ba271 <unavailable> + 1811057 9 swift-frontend 0x000000000056ddc3 <unavailable> + 1498563 10 swift-frontend 0x000000000056d5f7 <unavailable> + 1496567 11 swift-frontend 0x000000000056135e <unavailable> + 1446750 12 swift-frontend 0x00000000004b0646 <unavailable> + 722502 13 libc.so.6 0x00007f8a321f6b10 __libc_start_main + 231 14 swift-frontend 0x00000000004b027a <unavailable> + 721530 Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace. Stack dump: 0. Program arguments: /usr/bin/swift-frontend -frontend -interpret - -disable-objc-interop -new-driver-path /usr/bin/swift-driver -resource-dir /usr/lib/swift -module-name main 1. Swift version 5.5-dev (LLVM c315411fac10439, Swift 424bc4056fc81c2) 2. 3. While running user code "<stdin>" Stack dump wit (edited)