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-11410] Pretty printed, JSON encoded empty array is different on Darwin vs Linux #3289

Closed
mbrandonw opened this issue Sep 2, 2019 · 2 comments
Assignees

Comments

@mbrandonw
Copy link

Previous ID SR-11410
Radar None
Original Reporter @mbrandonw
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Foundation
Labels Bug
Assignee @spevans
Priority Medium

md5: 565bb112f7f443a762ee5ddbb53785ac

Issue Description:

Empty arrays are encoded into a JSON string in different ways on Darwin and Linux. This test will pass on Darwin:

  func testEmptyArray() throws {
    let encoder = JSONEncoder()
    encoder.outputFormatting = .prettyPrinted
    let value: [Int] = []

    XCTAssertEqual(String.init(decoding: try encoder.encode(value), as: UTF8.self) , """
[

]
""")
  }

but fails on Linux:

XCTAssertEqual failed: ("[
  
]") is not equal to ("[

]") - 
@mbrandonw
Copy link
Author

I'm realizing that this also happens with empty objects.

@spevans
Copy link
Collaborator

spevans commented Oct 31, 2019

#2551

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 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

2 participants