Skip to content

JSONSerialization works differently on platforms #5173

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

Open
Ildarec11 opened this issue Feb 20, 2025 · 0 comments
Open

JSONSerialization works differently on platforms #5173

Ildarec11 opened this issue Feb 20, 2025 · 0 comments

Comments

@Ildarec11
Copy link

If you run the following code on macOS, the output will be 68.31999999999999:

let jsonString = """
{
    "amount": 68.32
}

let json = jsonString.data(using: .utf8)!
let serialized = try JSONSerialization.jsonObject(with: json) as! [String: Any]

let amount = serialized["amount"]
print(amount)

However, if you run the same code on SwiftFiddle (using the x86_64-unknown-linux-gnu platform), the output will be 68.32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant