Skip to content

[SR-13173] Foundation.JSONEncoder + Swift 5.2.4 + .allowFragments difference between macOS and Linux #3248

@ktoso

Description

@ktoso
Previous ID SR-13173
Radar rdar://problem/65213214
Original Reporter @ktoso
Type Bug
Status Resolved
Resolution Done
Environment

Ubuntu, Swift 5.2.4-RELEASE

Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug, Codable
Assignee None
Priority Medium

md5: 4e72ea41a8582e0940c613e2d3fc8e5f

Issue Description:

I'm aware and very happy that this was fixed on master and will be fixed in Swift 5.3: #2713 ( https://bugs.swift.org/browse/SR-12275 https://bugs.swift.org/browse/SR-6163 ).

Things are not in sync between corelibs foundation and foundation on 5.2.4 though, which causes us a bunch of painful workaround and headaches - is there a chance that the patch will also apply to any 5.2.x if/when there's going to be one?

macOS, swift 5.2.4, good:

Welcome to Apple Swift version 5.2.4 (swift-5.2.4-RELEASE).
 1> import Foundation
 3> JSONDecoder().decode(Int.self, from: "23".data(using: .utf8)!)
$R1: Int = 23

ubuntu, swift 5.2.4, bad:

Welcome to Swift version 5.2.4 (swift-5.2.4-RELEASE).
1> import Foundation
3> let s = JSONDecoder().decode(Int.self, from: "42".data(using: .utf8)!)
s: Int = 0 // oh oh...

Things are correct on Swift 5.3, however we're not really ready to require users to bump to that version, so we're stuck with building manually looking ahead at the bytes if it maybe it a top level value and trying to handle it "manually" today...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions