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-4849] Fixed integer widths not supported as JSON objects on Linux #47426

Closed
alblue opened this issue May 10, 2017 · 0 comments
Closed

[SR-4849] Fixed integer widths not supported as JSON objects on Linux #47426

alblue opened this issue May 10, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@alblue
Copy link
Contributor

alblue commented May 10, 2017

Previous ID SR-4849
Radar None
Original Reporter @alblue
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 8df5f3d2bd14addf4919e5266cb9f0cd

duplicates:

  • SR-4475 JSONSerialization cannot serialize UInt8 on Linux

Issue Description:

The check in isValidJSONObject on Linux only checks for generic-width ints (Int, UInt) and not explicit sized widths (e.g. Int8)

            // object is Swift.String, NSNull, Int, Bool, or UInt
            if obj is String || obj is NSNull || obj is Int || obj is Bool || obj is UInt {
                return true
            }

As a result, this code behaves differently on Linux and Darwin:

import Foundation

let i64:Int64 = 1
let i:Int = 1

print( [JSONSerialization.isValidJSONObject(["int64":i64]),
  JSONSerialization.isValidJSONObject(["int":i])]) 

On Darwin, this prints

[true, true]

On Linux, this prints

[false, true]

Adding explicitly sized integer widths (Int64, Int8 etc.) into the isValidObject should fix the problem.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant