Skip to content

[SR-5961] JSONSerialization does not properly convert 1.1 #4412

Open
@swift-ci

Description

@swift-ci
Previous ID SR-5961
Radar None
Original Reporter rexmas (JIRA User)
Type Bug

Attachment: Download

Environment

Mac OS 10.12.6
MacBook Pro (Retina, 15-inch, Late 2013)

iOS 11

Xcode 9

Swift 4 and Swift 3.2

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

md5: fb6921cbf1fa090db8d7f39e528d14b4

relates to:

  • SR-106 description returns a rounded value of Double
  • SR-454 Reimplement float -> string with better algorithms
  • SR-7195 JSONSerialization encodes Double differently on Darwin and Linux

Issue Description:

type this in a Playground, see "[1.1000000000000001]"

let options = JSONSerialization.WritingOptions(rawValue: 0)
let data = try JSONSerialization.data(withJSONObject: [1.1], options: options)
let string = String(data: data, encoding: .utf8)

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