Skip to content

[SR-2694] Cannot JSON serialize array with boolean value #4514

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-2694
Radar None
Original Reporter saiHema (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee saiHema (JIRA)
Priority Medium

md5: 216c7a16ed8c93d5468c3eabaaca7d5c

relates to:

  • SR-3013 JSONSerialization coerces booleans to numbers on Linux

Issue Description:

import Foundation
JSONSerialization.data(withJSONObject: [true])

on macOS (0829) and Ubuntu 15.10 (0905) REPLs. This code runs on macOS but errors in Ubuntu with this message:

$E0: Error = {
instance_type = {
Foundation.NSObject = {}
_domain = "NSCocoaErrorDomain"
_code = 3840
_userInfo = 1 key/value pair {
[0] = {
key = "NSDebugDescription"
value = "Invalid object cannot be serialized"
}
}
}
}
Also
import Foundation
JSONSerialization.isValidJSONObject([1]) returns true on macOS and false on linux

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