Swiftpack.co - ITzTravelInTime/TINUSerialization as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ITzTravelInTime.
ITzTravelInTime/TINUSerialization 0.0.2
Library with useful extensions to `Decodable` and `Encodable` (and so also `Codable`) types, including simple JSON/Plist serialization and deserialization.
⭐️ 0
🕓 15 weeks ago
iOS macOS
.package(url: "https://github.com/ITzTravelInTime/TINUSerialization.git", from: "0.0.2")


Library with useful extensions to Decodable and Encodable (and so also Codable) types, including simple JSON/Plist serialization and deserialization.

Features and usage

The main feature of this library are the extensions for Decodable and Encodable (and so also Codable) types.

Here are some examples of intended usages:

import Foundation
import TINUSerialization

///Tesing struct, to be able to use this library it must conform to `Codable` and `FastCodable` or `GenericCodable` and `FastCdable`.
struct Foo: Codable, FastCodable{
    let bar_string: String
    let bar_integer: Int

//extension Dictionary: GenericCodable {  }

//Testing initialization of the struct
let test = Foo.init(bar_string: "Test", bar_integer: 30)

//testing serialization to json
print("Obtained json string: \n" + (test.json(usingFormatting: .prettyPrinted) ?? "") + "\n\n")

//testing serialization to plist
print("Obtained plsit string: \n" + (test.plist() ?? "") + "\n\n")

//creating new instance from a json deserialization
print("Testing json de-serialization: \(Foo.init(fromJSONSerializedString: test.json(usingFormatting: nil) ?? "")!) \n\n")

//creating new instance from a plist deserialization
print("Testing plist de-serialization: \(Foo.init(fromPlistSerialisedString: test.plist() ?? "")!) \n\n")

//creating new instance from a remote json file
print("Testing remote json de-serialization: \( Foo.init(fromRemoteFileAtUrl: "https://raw.githubusercontent.com/ITzTravelInTime/TINUSerialization/main/Test.json" )! ) \n\n")

//creating new instance from a remote plist file
print("Testing remote plist de-serialization: \( Foo.init(fromRemoteFileAtUrl: "https://raw.githubusercontent.com/ITzTravelInTime/TINUSerialization/main/Test.plist" )! ) \n\n")

Who should use this Library?

This library should be used by Swift apps/programs that needs to perform simple operations with JSON/Plist serializaed objects, either by fetching data locally or remotely.

This code is tested on apple platfroms and the official Swift docker container.

About the project

This code was created as part of my TINU project (https://github.com/ITzTravelInTime/TINU) and has been separated and made into it's own library to make the main project's source less complex and more focused on it's aim.

Also having it as it's own library allows for code to be updated separately and so various versions of the main TINU app will be able to be compiled all with the latest version of this library.

Libraries used



Legal info

TINUSerialization: A library for the usage of serialization formats in Swift. Copyright (C) 2021-2022 Pietro Caruso

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

15 weeks ago
  • Improved Xcode 12 compatibility by using more recent versions of the dependancies.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics