• This repository has been archived on 23/Mar/2021
  • Stars
    star
    132
  • Rank 265,533 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pure-Swift JSON parser & formatter. Fully streamable input and output. Linux & OS X ready. Replacement for NSJSONSerialization.

Jay

Build Status Latest Release Platforms Package Managers

Pure-Swift JSON parser & formatter. Fully streamable input and output. Linux & OS X ready. Replacement for NSJSONSerialization.

Jay conforms to the following specifications:

For extra convenience functions when working with the JSON enum, check out Jay-Extras.

Why?

We all use JSON. Especially when writing server-side Swift that needs to run on Linux. #0dependencies

This is my take on how a JSON parser should work. This is not another JSON mapping utility library. This is an actual JSON parser and formatter. Check out the code, it was fun to write 😇

Features

  • Parsing: data -> JSON object
  • Formatting: JSON object -> data
  • Pretty printing
  • Streaming input and output, low memory footprint

Usage

Parsing from data (deserialization)

do {
	//get data from disk/network
	let data: [UInt8] = ...

	//ask Jay to parse your data
	let json = try Jay().jsonFromData(data) // JSON
	//or
	let json = try Jay().anyJsonFromData(data) // [String: Any] or [Any]

	//if it doesn't throw an error, all went well
	if let tasks = json.dictionary?["today"]?.array {
	    //you have a dictionary root object, with an array under the key "today"
	    print(tasks) //["laundry", "cook dinner for gf"]
	} 
} catch {
	print("Parsing error: \(error)")
}

Formatting into data (serialization)

do {
	//get a json object (works for both [String: Any] and typesafe versions - JSON)

	//ask Jay to generate data
	let anyContainer = ... // [String: Any] or [Any]
	let data = try Jay(formatting: .prettified).dataFromJson(any: json) // [UInt8]
	//or
	let json: JSON = ... // JSON
	let data = try Jay(formatting: .prettified).dataFromJson(json: json) // [UInt8]

	//send data over network, save to disk
} catch {
	print("Formatting error: \(error)")
}

Installation

Swift Package Manager

.Package(url: "https://github.com/czechboy0/Jay.git", majorVersion: 1)

💙 Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

💝 Contributing

Please create an issue with a description of your problem or open a pull request with a fix.

✌️ License

MIT

👽 Author

Honza Dvorsky - http://honzadvorsky.com, @czechboy0

More Repositories

1

Latch

A simple Swift Keychain Wrapper for iOS, watchOS, and OS X.
Swift
57
star
2

Watchman

A WatchOS2 Hangman Game - Made at the iOSDevUK2015 Hackathon
Swift
54
star
3

keylightctl

CLI for managing Elgato Keylight (Air)
Go
39
star
4

swiftpm-dependency-fetcher

Dependencies of your SwiftPM packages as a service.
JavaScript
37
star
5

Stash

A parallel object cache for Swift 2.0
Swift
24
star
6

dotfiles

things that give computers my special brand of depression
Shell
24
star
7

Persist

A simple Swift 2.0 Core Data stack using parent/child contexts
Swift
24
star
8

Leeroy

[WIP] Automatically provision a clean Mac Mini/VM with the tools required for iOS CI and testing.
Shell
21
star
9

Bees

A Swarm/Foursquare API Client written in Elixir
Elixir
19
star
10

twentysix

A tiny wrapper around the n26 banking api
Ruby
18
star
11

Sails

A Simple Swift Web Framework. Made at Hackference 2015
Swift
11
star
12

swift-package-converter

API to convert Package.swift files into JSON
Swift
10
star
13

whereis

Ruby
10
star
14

Time-Buddy

A simple OS X widget to display time zones. Built on a train from Köln to Berlin.
Swift
10
star
15

DANPromise

A threadsafe, lightweight implementation of Promises in Objective-C
Objective-C
10
star
16

keylight-go

A go library for interacting with the Elgato Key Light and Key Light Air
Go
9
star
17

DANOpenInMacVim

An Xcode Plugin to open the current file in MacVim
Objective-C
8
star
18

swift-rest-demo

7
star
19

Hive

A simple WatchKit app for Swarm checkins. Written in Swift. Not quite finished. Kinda Hacky.
Swift
7
star
20

DANCurlRequest

Quickly dump NSURLRequests as curl strings.
Objective-C
7
star
21

nomad-plugin-firecracker

WIP
Go
6
star
22

nixos-config

My nixos system configurations
Nix
6
star
23

docker-swiftlint

A Docker Image for running SwiftLint on CI
Makefile
6
star
24

MondoSquared

Automatically check into foursquare when using your Mondo card
JavaScript
5
star
25

actions

Shell
5
star
26

BestThread

Ruby
5
star
27

AssetGen

A small Swift command line tool for generating Swift code for Asset Catalog resources
Swift
4
star
28

Resource

Library for building REST API's with Frank
Swift
4
star
29

kaniko-test

Proof of concept of using kaniko to build container images in a CircleCI job
Dockerfile
3
star
30

speaking

Upcoming Talks
3
star
31

Jay-C7

C7 conformance for Jay
Swift
3
star
32

cocoapods-orb

Swift
3
star
33

cocoapods_issue_bot

CocoaPods Issue Helper
Ruby
3
star
34

CachelessBrowserMac

Objective-C
3
star
35

DANAdditions

Objective-C
3
star
36

buildkite-gcp-scaler

A simple autoscaler for running buildkite jobs on Google Cloud
Go
3
star
37

Jay-Extras

Extra conveniences for Jay
Swift
3
star
38

xctestrunner

[WIP] Automatic XCTest runner
Ruby
3
star
39

Code-Standards

3
star
40

gistli

A simple cli for gists. With a hard G.
Go
3
star
41

cocoapods-ci

Ruby
3
star
42

nomad-extras

Go
2
star
43

vim-sms

Ruby
2
star
44

dynamic-dns-cloudflare

Go
2
star
45

notify

A tiny little Go proxy for sending Slack Notifications
Go
2
star
46

theobroma

[WIP] A CocoaPods Version manager. Ideally you should use Bundler instead.
Ruby
2
star
47

fastlane-plugin-asciii

Ruby
2
star
48

windows

A collection of random windows things
PowerShell
2
star
49

git-summarize-branch

Go
2
star
50

SqSlidr

An Open-Source Slider, based upon that by Square.
CSS
2
star
51

docker-danger

2
star
52

docker-terraform-tflint

1
star
53

TweetMap

R
1
star
54

mondo-swift

A WIP concept API Client for the Mondo API
Swift
1
star
55

goodreads-to-book-mode

Rust
1
star
56

kitty-fairyfloss

because your terminal should be pretty.
1
star
57

UIImage-Generate

Generate flat and gradient images with code!
Objective-C
1
star
58

docker-protobuf

Dockerfile
1
star
59

www.getcaptain.com

The website used for my upcoming app, Captain.
HTML
1
star
60

FruitConf-CustomKeyboardExampleSwift

Swift
1
star
61

Koffein

Swift
1
star
62

specs-test

1
star
63

spin-trigger-tailscale

Rust
1
star
64

LastTrack

Last track is a quick and simple way of grabbing the last track played from LastFM, so connect your spotify/itunes etc and pass this your LastFM name.
Ruby
1
star
65

cert-manager-community-day

An example of using cert-manager to configure a Kubernetes webhook
Go
1
star
66

xcode-log-parse

Rust
1
star
67

DANReactiveLocationManager

A ReactiveCocoa Wrapper to get a users location.
Objective-C
1
star
68

git-promote

Shell
1
star
69

etcd-test-analyzer

Go
1
star
70

Moving-To-Berlin

A place for me to keep things while I plan my move to ⊂(・(ェ)・)⊃
1
star
71

DANGoogleSignIn

A quick wrapper around Google's web authentication for mobile devices.
Objective-C
1
star
72

development-environment

Python
1
star
73

setup-nomad

A GitHub Action to install HashiCorp's Nomad.
TypeScript
1
star
74

Rust

Rust
1
star
75

KittyKit

A Swift framework for interacting with small.cat
Swift
1
star
76

DANLinkedStoryboardSegue

Objective-C
1
star
77

FacebookD8-PhotoLinkr

Objective-C
1
star
78

Propeller

An open-source push notification API. - Not currently finished.
Ruby
1
star
79

Ignition

This will be a quick launcher and Today Extension for iOS
Swift
1
star
80

swiftwasm-test

A repo testing Spin + SwiftWasm with WASI
C
1
star