Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

JSON Fragment Decoding

A JSONDecoder extension to allow decoding JSON fragments.

Usage

Simply pass allowFragments: true to a JSONDecoder.decode(_:from:) call, and you’ll be able to decode JSON fragments:

import Foundation
import JSONFragmentDecoding

let data = Data("10".utf8)

let decoded = try JSONDecoder().decode(Int.self, from: data, allowFragments: true)
print(decoded) // 10

Installation

Honestly it’s so lightweight that you could just drop /Sources/JSONFragmentDecoding/JSONFragmentDecoding.swift into your project and be on your way.

Swift PM

Add the following dependancy to your Package.swift file:

dependencies: [
  .package(url: "https://github.com/hamishknight/JSON-Fragment-Decoding.git", from: "0.1.0")
],

and then add the dependancy to any targets that need to use it:

targets: [
  .target(
    name: "SomeTarget",
    dependencies: ["JSON-Fragment-Decoding"]),
]

Carthage

Add the following to your Cartfile:

github "hamishknight/JSON-Fragment-Decoding" ~> 0.1

About

A JSONDecoder extension to allow decoding JSON fragments

Topics

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.