Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12275] JSONEncoder on Linux can't encode number JSON fragments #4396

swift-ci opened this issue Feb 26, 2020 · 2 comments

[SR-12275] JSONEncoder on Linux can't encode number JSON fragments #4396

swift-ci opened this issue Feb 26, 2020 · 2 comments


Copy link

@swift-ci swift-ci commented Feb 26, 2020

Previous ID SR-12275
Radar rdar://problem/59830261
Original Reporter xavier.lowmiller (JIRA User)
Type Bug
Status Resolved
Resolution Done

I tested this in the 5.1.4 Swift Docker Container from\_/swift

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee @spevans
Priority Medium

md5: 824ef3e9951a0e0fa1f7b095708f76f3

relates to:

  • SR-6163 JSONDecoder cannot decode RFC 7159 JSON

Issue Description:

Consider the following program:

import Foundation

let data = 2

do {
    let stored = try String(data: JSONEncoder().encode(data), encoding: .utf8)!


    print(try JSONDecoder().decode(Int.self, from: Data(stored.utf8)))

} catch {

On macOS, this will work: The `JSONEncoder` produces a `Data` with contents `2`.

On Linux, this prints the following error:

invalidValue(2, Swift.EncodingError.Context(codingPath: [], debugDescription: "Top-level Int encoded as number JSON fragment.", underlyingError: nil))
Copy link

@hborla hborla commented Feb 27, 2020

@swift-ci create

Copy link

@spevans spevans commented Mar 4, 2020


@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants