outfoxx / potentcodables Goto Github PK
View Code? Open in Web Editor NEW🧪 PotentCodables - A potent set of implementations and extensions to the Swift Codable system
License: MIT License
🧪 PotentCodables - A potent set of implementations and extensions to the Swift Codable system
License: MIT License
I just deleted / commented out all the YAML stuff and all the tests pass on Windows. I only need CBOR support, and was wondering whether you'd consider breaking PotentCodables into separate packages?
Because Cfyaml uses autoconf, I anticipate difficulty porting it to Windows, but it's possible it could work if I can find a replacement unistd.h. But all of those are long-term solutions. I'd rather not fork your library, but it seems to be the only actively-maintained implementation of CBOR coding anywhere.
Although, now that I look at your docs, I'm not sure whether you actually supply the functionality I need. I want to accomplish essentially this (that package also has portability problems and is not currently passing its own tests).
Does PotentCodables do that? What I see in the docs (though I may have missed it) looks like it's for dynamically traversing already-serialized CBOR representations, but I have an existing Codable data structure that I want to serialize and deserialize.
Thanks!
Hi,
I'm having some issues with the versioning scheme. How can I encode the following structure in asn1: Version ::= INTEGER { v1(1) }
, in other words, how should structure and scheme look like?
Thanks for your help in advance,
Nico
This is a great library, can you add it to cocoapods to make easier for ppl to import? Or to source integration? Thanks!
My solution which solves the issue:
PotentCodables/Sources/PotentASN1/ASN1Reader.swift
case .generalizedTime:
let string = try parseString(&itemBuffer, tag: tag, encoding: .ascii)
let dateFormatter: DateFormatter
if string.contains(".") {
dateFormatter = generalizedFormatter
} else {
dateFormatter = generalizedFormatterWithoutMillis
}
return .generalizedTime(dateFormatter.date(from: string)!)
private let generalizedFormatterWithoutMillis: DateFormatter = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyyMMddHHmmssXXXXX"
return formatter
}()
I can push and make a PR if it's OK.
Hey!
I'm seeing a weird bug where a dictionary is getting encoded as an array? This didn't used to happen in older version (I tried on v1.8.2)
Example code to reproduce the issue:
import Foundation
import PotentCodables
func main() {
var myDict = [String: [String: AnyValue]]()
myDict["key"] = ["innerVal": AnyValue.bool(true)]
myDict["key2"] = ["innerDict": AnyValue.dictionary([
"innerKey": true
])]
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
if let data = try? encoder.encode(myDict), let json = String.init(data: data, encoding: .utf8) {
print(json)
}
}
main()
Output on current main:
{
"key" : {
"innerVal" : true
},
"key2" : {
"innerDict" : [
"innerKey",
true
]
}
}
Output on 1.8.2:
{
"key" : {
"innerVal" : true
},
"key2" : {
"innerDict" : {
"innerKey" : true
}
}
}
It seems like the BidirectionalCollection and Collection protocols has changed.
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: type 'AnyString' does not conform to protocol 'BidirectionalCollection'
extension AnyString: StringProtocol {
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: unavailable subscript 'subscript(:)' was used to satisfy a requirement of protocol 'BidirectionalCollection'
extension AnyString: StringProtocol {
^
Swift.Collection:3:12: note: 'subscript(:)' declared here
public subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
Swift.BidirectionalCollection:14:14: note: requirement 'subscript(:)' declared here
override subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: type 'AnyString' does not conform to protocol 'Collection'
extension AnyString: StringProtocol {
^
/Users/johansellstrom/PotentCodables/Sources/PotentASN1/AnyString.swift:62:1: error: unavailable subscript 'subscript(:)' was used to satisfy a requirement of protocol 'Collection'
extension AnyString: StringProtocol {
^
Swift.Collection:3:12: note: 'subscript(:)' declared here
public subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
Swift.Collection:12:5: note: requirement 'subscript(:)' declared here
subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
^
Hi, thank you for creating such a piece of art. This project helps a lot.
Here, I has a doubt: Why the minimum deployment target of macOS was set to 10.12?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.