Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Took out C7 support in Jay repo, will add that support to a separate …
Browse files Browse the repository at this point in the history
…Jay+C7 repo (#33)

* Took out C7 support in Jay repo, will add that support to a separate Jay+C7 repo

* upgraded to 06-20

* travis update

* readme
  • Loading branch information
czechboy0 authored Jul 22, 2016
1 parent c20500a commit 97f3e7b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DEVELOPMENT-SNAPSHOT-2016-06-06-a
DEVELOPMENT-SNAPSHOT-2016-06-20-a
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ os:
language: generic
sudo: required
dist: trusty
osx_image: xcode7.3
osx_image: xcode8
install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/02090c7ede5a637b76e6df1710e83cd0bbe7dcdf/swiftenv-install.sh)"
script:
Expand Down
6 changes: 1 addition & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import PackageDescription
let package = Package(
name: "Jay",
targets: [
Target(name: "Jay"),
Target(name: "JayExample", dependencies: [.Target(name: "Jay")])
],
dependencies: [
.Package(url: "https://github.com/open-swift/C7.git", versions: Version(0,8,0)..<Version(1,0,0))
Target(name: "JayExample", dependencies: ["Jay"])
]
)
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Jay conforms to the following specifications:
- JSON [RFC4627](http://www.ietf.org/rfc/rfc4627.txt)
- [Open Swift C7 JSON](https://github.com/open-swift/C7/blob/master/Sources/JSON.swift)
- [Open Swift C7 JSON](https://github.com/open-swift/C7/blob/master/Sources/JSON.swift) with the use of [Jay-C7](https://github.com/czechboy0/Jay-C7)

# :question: Why?
We all use JSON. Especially when writing server-side Swift that needs to run on Linux. `#0dependencies`
Expand All @@ -34,7 +34,7 @@ do {
let data: [UInt8] = ...

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

Expand All @@ -57,7 +57,7 @@ do {
let anyContainer = ... // [String: Any] or [Any]
let data = try Jay(formatting: .prettified).dataFromJson(any: json) // [UInt8]
//or
let json: JSON = ... // C7.JSON
let json: JSON = ... // JSON
let data = try Jay(formatting: .prettified).dataFromJson(json: json) // [UInt8]

//send data over network, save to disk
Expand All @@ -71,7 +71,7 @@ do {
## Swift Package Manager

```swift
.Package(url: "https://github.com/czechboy0/Jay.git", majorVersion: 0, minor: 12)
.Package(url: "https://github.com/czechboy0/Jay.git", majorVersion: 0, minor: 14)
```

:blue_heart: Code of Conduct
Expand Down
31 changes: 13 additions & 18 deletions Sources/Jay/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,21 @@
// Copyright © 2016 Honza Dvorsky. All rights reserved.
//

@_exported import enum C7.JSON

typealias JChar = UTF8.CodeUnit

//public enum JSON {
//
// public enum Number {
// case integer(Int)
// case double(Double)
// }
//
// case object([String: JSON])
// case array([JSON])
// case number(Number)
// case string(String)
// case boolean(Bool)
// case null
//}


public enum JSON {
public enum Number {
case integer(Int)
case unsignedInteger(UInt)
case double(Double)
}
case object([String: JSON])
case array([JSON])
case number(Number)
case string(String)
case boolean(Bool)
case null
}



14 changes: 7 additions & 7 deletions Tests/Jay/PerformanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import XCTest
#else
class PerformanceTests: XCTestCase {

func urlForFixture(_ name: String) -> NSURL {
func urlForFixture(_ name: String) -> URL {

let parent = (#file).components(separatedBy: "/").dropLast().joined(separator: "/")
let url = NSURL(string: "file://\(parent)/Fixtures/\(name).json")!
let url = URL(string: "file://\(parent)/Fixtures/\(name).json")!
print("Loading fixture from url \(url)")
return url
}
Expand All @@ -39,10 +39,10 @@ class PerformanceTests: XCTestCase {
return data
}

func loadFixtureNSData(_ name: String) -> NSData {
func loadFixtureNSData(_ name: String) throws -> Data {

let url = self.urlForFixture(name)
let data = NSData(contentsOf: url)!
let data = try Data(contentsOf: url)
return data
}

Expand All @@ -61,11 +61,11 @@ class PerformanceTests: XCTestCase {
}
}

func testPerf_ParseLargeJson_Darwin() {
func testPerf_ParseLargeJson_Darwin() throws {

let data = self.loadFixtureNSData("large")
let data = try self.loadFixtureNSData("large")
measure {
_ = try! NSJSONSerialization.jsonObject(with: data, options: [])
_ = try! JSONSerialization.jsonObject(with: data, options: [])
}
}

Expand Down

0 comments on commit 97f3e7b

Please sign in to comment.