ProductPromotion
Logo

Swift

made by https://0x3d.site

GitHub - SomeRandomiOSDev/CBORCoding: Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.
Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS. - SomeRandomiOSDev/CBORCoding
Visit Site

GitHub - SomeRandomiOSDev/CBORCoding: Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.

GitHub - SomeRandomiOSDev/CBORCoding: Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.

CBORCoding

License MIT CocoaPods Compatible Carthage Compatible Platform Code Coverage

Carthage Cocoapods Documentation Swift Package SwiftLint XCFramework Xcode Project

CBORCoding is a lightweight framework containing a coder pair for encoding and decoding Codable conforming types to and from CBOR document format for iOS, macOS, tvOS, and watchOS.

Installation

CBORCoding is available through CocoaPods, Carthage and the Swift Package Manager.

To install via CocoaPods, simply add the following line to your Podfile:

pod 'CBORCoding'

To install via Carthage, simply add the following line to your Cartfile:

github "SomeRandomiOSDev/CBORCoding"

To install via the Swift Package Manager add the following line to your Package.swift file's dependencies:

.package(url: "https://github.com/SomeRandomiOSDev/CBORCoding.git", from: "1.0.0")

Usage

First import CBORCoding at the top of your Swift file:

import CBORCoding

After importing, the use is nearly identical to that of the JSONEncoder/JSONDecoder class pair provided by the Swift Foundation library. This example shows how to encode an instance of a simple Car type to a CBOR object:

struct Car: Codable {
    var manufacturer: String
    var model: String
    var horsePower: Int
    var description: String?
}

let stinger = Car(manufacturer: "Kia", model: "Stinger GT2", horsePower: 365, description: nil)  
let encoder = CBOREncoder()

let encodedData = try encoder.encode(stinger)
print("CBOR: \(hexString(encodedData))")

/* Prints:
 CBOR: 0xA36C6D616E756661637475726572634B6961656D6F64656C6B5374696E676572204754326A686F727365506F77657219016D
*/

This example shows how to decode that encoded Car value at a later time:

let decoder = CBORDecoder()
let stinger = try decoder.decode(Car.self, from: encodedData)

CBOR

Concise Binary Object Representation is a data format for being able to encode formatted data with a goal of a having as small a message size as possible.

While this framework implements as much of the specification as possible, there are a few notable exceptions:

  • CBOR supports keys of any defined type, however, since Codable relies on CodingKey for encoding/decoding its keyed containers, this framework is limited in its supported key types to Int and String.
  • CBOR supports DecimalFractions and Bigfloats whose mantissa is a Bignum. With the current implementation, this is limited to Bignums whose content fits into either a Int64 or UInt64 type.

For more information about the CBOR format see: CBOR & RFC 8949.

Contributing

Whether it's submitting a feature request, reporting a bug, or writing code yourself, all contributions to this library are welcome! Please see CONTRIBUTING for more information on how you can contribute.

Author

Joe Newton, [email protected]

Credits

CBORCoding is based heavily on the JSONEncoder/JSONDecoder classes provided by Swift. See ATTRIBUTIONS for more details.

License

CBORCoding is available under the MIT license. See the LICENSE file for more info.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory