Skip to content

rintaro/swift-JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swift-JSON

Swift: 3.0.1 platforms: macOS, iOS, tvOS, Linux Carthage: compatible SwiftPM: compatible

JSON

Yet another Swift JSON encoder/decoder. Intended to be RFC7159 compliant.

Getting Started

Swift Package Manager

import PackageDescription

let package = Package(
    name: "hello",
    dependencies: [
        .Package(url: "https://github.com/rintaro/Swift-JSON.git", majorVersion: 0, minor: 2),
    ]
)

Carthage

github "rintaro/swift-JSON" ~> 0.2

Using JSON

decode

(a.k.a. parse or deserialize)

import JSON

let jsonData: Data = ...

do {

    let value = try JSON.decode(jsonData)
    // do something...

} catch let e as JSONParsingError {
    print(e)
}

encode

(a.k.a. dump or serialize)

import JSON

let value: Any = ...

do {

    let data = try JSON.encode(value)
    // do something...

} catch let e as JSONPrintingError {
    print(e)
}

Requirements

  • Swift 3.0.1 (Xcode8.1 on macOS)
  • Foundation

About

Simple JSON encoder/decoder

Resources

License

Stars

Watchers

Forks

Packages

No packages published