Open iq3addLi opened 8 years ago
Use Vapor 1.0.3 contains Jay. Xcode 8.0.
.Package(url: "https://github.com/DanToml/Jay.git", majorVersion: 1)
func dictionaryToJayType(_ maybeDictionary: Any) throws -> JSON? { let mirror = Mirror(reflecting: maybeDictionary) let childrenValues = mirror.children.map { $0.value } var obj = [String: JSON]() for i in childrenValues { let childMirror = Mirror(reflecting: i) let children = childMirror.children if childMirror.displayStyle == .tuple && children.count == 2 { let it = children.makeIterator() let maybeKey = it.next()!.value guard let key = maybeKey as? String else { throw JayError.keyIsNotString(maybeKey) } let value = it.next()!.value obj[key] = try self.toJayType(value) // Int 1 -> .boolean(true) } else { throw JayError.unsupportedType(childMirror) } } return .object(obj) }
Use Vapor 1.0.3 contains Jay. Xcode 8.0.
.Package(url: "https://github.com/DanToml/Jay.git", majorVersion: 1)