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

Linux compatibility #6

Closed
michaeleisel opened this issue Aug 22, 2019 · 3 comments
Closed

Linux compatibility #6

michaeleisel opened this issue Aug 22, 2019 · 3 comments

Comments

@michaeleisel
Copy link
Owner

Right now, it only works with iOS and MacOS. Some things will need to be reworked for Linux (it basically can't use Objective-C)

@michaeleisel
Copy link
Owner Author

Closing due to low demand

@b-ncMN
Copy link

b-ncMN commented Jun 22, 2022

Hey,

This would be a very cool feature to have
(sure, I'm the only one asking for it, very low demand)
We use ZippyJSON in our Swift Minecraft client and would love to see Linux support land

@ninjadev64
Copy link

In the meantime, anyone looking for a workaround may be able to use this wrapper.

import Foundation
#if !os(Linux)
import ZippyJSON
#endif

public struct CustomJSONDecoder {
  #if !os(Linux)
  public var keyDecodingStrategy: ZippyJSONDecoder.KeyDecodingStrategy = ZippyJSONDecoder.KeyDecodingStrategy.useDefaultKeys
  #else
  public var keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = JSONDecoder.KeyDecodingStrategy.useDefaultKeys
  #endif

  public init() {
    // Empty initialiser because we do not want the keyDecodingStrategy to be an initialiser parameter
  }

  public func decode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T {
    #if !os(Linux)
    let decoder = ZippyJSONDecoder()
    #else
    let decoder = JSONDecoder()
    #endif
    decoder.keyDecodingStrategy = self.keyDecodingStrategy
    return try decoder.decode(type, from: data)
  }
}

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

3 participants