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-4475] JSONSerialization cannot serialize UInt8 on Linux #4532

Closed
swift-ci opened this issue Apr 3, 2017 · 3 comments
Closed

[SR-4475] JSONSerialization cannot serialize UInt8 on Linux #4532

swift-ci opened this issue Apr 3, 2017 · 3 comments

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Apr 3, 2017

Previous ID SR-4475
Radar None
Original Reporter ylin (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 3.1, Ubuntu 16.04

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

md5: 16c574ff67fde808bbc831290032b61b

is duplicated by:

  • SR-4849 Fixed integer widths not supported as JSON objects on Linux

relates to:

  • SR-1610 Cross-platform NSNumber coercion behavior

Issue Description:

Sample code:

import Foundation

let a: UInt8 = 1
let arr = [a, a, a]

print("Is array of UInt8 valid JSON? \(JSONSerialization.isValidJSONObject(arr))")

Tested on 3.1.
On Ubuntu 16.04, it prints `Is array of UInt8 valid JSON? false`.
On OSX, it prints `Is array of UInt8 valid JSON? true`.

@swift-ci
Copy link
Contributor Author

swift-ci commented Apr 3, 2017

Comment by Alec O'Connor (JIRA)

This is the case for other types as well. Including CGFloats

@belkadan
Copy link

belkadan commented Apr 3, 2017

I think you have to manually create NSNumbers to be cross-platform compatible in Swift 3.1. Right, @phausler?

@spevans
Copy link
Collaborator

spevans commented Aug 6, 2018

This looks fixed in 4.1.3:

$ ~/swift-4.1.3-RELEASE-ubuntu16.04/usr/bin/swift
 Welcome to Swift version 4.1.3 (swift-4.1.3-RELEASE). Type :help for assistance.
 1> import Foundation 
 2. 
 3. let a: UInt8 = 1 
 4. let arr = [a, a, a] 
 5. 
 6. print("Is array of UInt8 valid JSON?
\(JSONSerialization.isValidJSONObject(arr))")
 Is array of UInt8 valid JSON? true

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

No branches or pull requests

3 participants