https://github.com/asoderman/jsondecoder
Simple JSON decoder written in swift
https://github.com/asoderman/jsondecoder
json parser parsing parsing-library swift
Last synced: 4 months ago
JSON representation
Simple JSON decoder written in swift
- Host: GitHub
- URL: https://github.com/asoderman/jsondecoder
- Owner: asoderman
- License: mit
- Created: 2017-11-14T03:42:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T23:01:10.000Z (about 8 years ago)
- Last Synced: 2025-09-15T21:32:41.227Z (5 months ago)
- Topics: json, parser, parsing, parsing-library, swift
- Language: Swift
- Size: 35.2 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple JSON Parser
Written in swift. [](https://travis-ci.org/asoderman/JSONDecoder)
### Installation:
Using SPM (in your Package.swift):
```swift
let package = Package(
name: "NameOfYourProject",
dependencies: [
.package(url: "https://github.com/asoderman/JSONDecoder.git", from: "0.1.5")
]
)
```
then
```
swift package resolve
```
### Usage:
Quickstart
```swift
let j = try! JSONParser(text: JSONTEXT).flatten()
let name = j["name"] as! String
let id = j["id"] as! Int
```
Error handling
```swift
do {
let j = try JSONParser(text: BADJSON).flatten()
let name = j["name"] as! String
let id = j["id"] as! Int
} catch {
// Do something
}
}
```
### To work on this library:
1. Fork this repo on github.
2. Create a local copy of your repo.
3. ```swift package generate-xcodeproj ```
4. Submit pull requests.