Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ github "hkellaway/Gloss" "master"
github "LoganWright/Genome" == 3.0.3
github "postmates/PMJSON" "master"
github "bignerdranch/Freddy" ~> 3.0

github "ikesyo/Himotoki" "master"
17 changes: 9 additions & 8 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
github "Anviking/Decodable" "ba6b6fb83e0df6f709acd5f2cdd9da8b49492708"
github "bignerdranch/Freddy" "3.0.2"
github "Anviking/Decodable" "3ba1bc350c84aecbaf24dc87c3cbc6ee4a118d19"
github "Hearst-DD/ObjectMapper" "2.2.7"
github "JohnSundell/Unbox" "4c0b4ae2f7aa10c17849e91231a4d2a04291bcfc"
github "LoganWright/Genome" "3.0.3"
github "hkellaway/Gloss" "27242cb5175958ce43395ff837f63967ba111d4a"
github "SwiftyJSON/SwiftyJSON" "121d6cc3715822145fd83b8679d7e1644b2e1c59"
github "bignerdranch/Freddy" "3.0.2"
github "hkellaway/Gloss" "e45facba610ceefd4796c264e0989d1947102e62"
github "ikesyo/Himotoki" "c8b03067aa0d72a9cf47185d99d4a13a2fca1f0e"
github "lyft/mapper" "db431abebe6b6ec632a3829edd75be0a440e331a"
github "postmates/PMJSON" "8d4c0a5cd5be1b53c00eef62db2b579a5777eb28"
github "utahiosmac/Marshal" "7a814e26312d5e7f1209168ca1a7860dcc12cf5f"
github "Hearst-DD/ObjectMapper" "2.2.2"
github "postmates/PMJSON" "c21e8b9dbf47db2f1a16d7aba453b7844c0cff10"
github "SwiftyJSON/SwiftyJSON" "adf34cfb4c9f2ff4e3c420c6d9fb1e2eaf3b3791"
github "JohnSundell/Unbox" "0466fcb72ee1454a302d3ee6640f19fec4c0e037"
github "vdka/json" "0.15.0"
github "lyft/mapper" "4031d7d7c8b111af564a4f5d5970cf5d68747a03"
20 changes: 20 additions & 0 deletions JSONShootout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
CCD5105B1CFFFF7000E9C0D1 /* SwiftyJSON_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD5105A1CFFFF7000E9C0D1 /* SwiftyJSON_Tests.swift */; };
CCFD5B551D0A718C0021C2B3 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCD510581CFFFB4C00E9C0D1 /* SwiftyJSON.framework */; };
CCFD5B571D0A71990021C2B3 /* SwiftyJSON.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CCD510581CFFFB4C00E9C0D1 /* SwiftyJSON.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
DF8DD6DC1ECFEDA0002B3D1A /* Himotoki.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF8DD6DB1ECFEDA0002B3D1A /* Himotoki.framework */; };
DF8DD6DD1ECFEDA0002B3D1A /* Himotoki.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DF8DD6DB1ECFEDA0002B3D1A /* Himotoki.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
DF8DD6E11ECFF587002B3D1A /* Himotoki.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF8DD6DB1ECFEDA0002B3D1A /* Himotoki.framework */; };
DF8DD6E31ECFF695002B3D1A /* Recording+Himotoki.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF8DD6E21ECFF695002B3D1A /* Recording+Himotoki.swift */; };
DF8DD6E51ED00848002B3D1A /* Program+Himotoki.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF8DD6E41ED00848002B3D1A /* Program+Himotoki.swift */; };
DF8DD6E71ED00BE9002B3D1A /* Himotoki_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF8DD6E61ED00BE9002B3D1A /* Himotoki_Tests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -114,6 +120,7 @@
files = (
CC7A7FB81DC053E400A69A0B /* Decodable.framework in Embed Frameworks */,
2098D54B1DC1F5E800A15075 /* Genome.framework in Embed Frameworks */,
DF8DD6DD1ECFEDA0002B3D1A /* Himotoki.framework in Embed Frameworks */,
681299071DBFFCBC009960BE /* ObjectMapper.framework in Embed Frameworks */,
CC3023441CF9616600B51746 /* Marshal.framework in Embed Frameworks */,
CC3023461CF9616700B51746 /* Mapper.framework in Embed Frameworks */,
Expand Down Expand Up @@ -195,6 +202,10 @@
CC9786C51CEBACE8005A5DEA /* Unbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Unbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CCD510581CFFFB4C00E9C0D1 /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = SwiftyJSON.framework; sourceTree = BUILT_PRODUCTS_DIR; };
CCD5105A1CFFFF7000E9C0D1 /* SwiftyJSON_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyJSON_Tests.swift; sourceTree = "<group>"; };
DF8DD6DB1ECFEDA0002B3D1A /* Himotoki.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Himotoki.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DF8DD6E21ECFF695002B3D1A /* Recording+Himotoki.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Recording+Himotoki.swift"; sourceTree = "<group>"; };
DF8DD6E41ED00848002B3D1A /* Program+Himotoki.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Program+Himotoki.swift"; sourceTree = "<group>"; };
DF8DD6E61ED00BE9002B3D1A /* Himotoki_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Himotoki_Tests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -206,6 +217,7 @@
20A0B96B1DC26810001D8A14 /* GenomeFoundation.framework in Frameworks */,
2098D54A1DC1F5E800A15075 /* Genome.framework in Frameworks */,
681299051DBFFCAB009960BE /* ObjectMapper.framework in Frameworks */,
DF8DD6DC1ECFEDA0002B3D1A /* Himotoki.framework in Frameworks */,
CCFD5B551D0A718C0021C2B3 /* SwiftyJSON.framework in Frameworks */,
716A8A9A1DC1D10A00BF314B /* Gloss.framework in Frameworks */,
CC7A7FB71DC053E400A69A0B /* Decodable.framework in Frameworks */,
Expand All @@ -232,6 +244,7 @@
files = (
2F2868961DE7F34B002A6F68 /* Freddy.framework in Frameworks */,
2098D54C1DC1F5FB00A15075 /* Genome.framework in Frameworks */,
DF8DD6E11ECFF587002B3D1A /* Himotoki.framework in Frameworks */,
716A8A9D1DC1D18B00BF314B /* JSON.framework in Frameworks */,
716A8A981DC1D0E900BF314B /* Gloss.framework in Frameworks */,
CCD510591CFFFB4C00E9C0D1 /* SwiftyJSON.framework in Frameworks */,
Expand All @@ -250,6 +263,7 @@
7C3FCD281DC1B16100C82DEE /* Frameworks */ = {
isa = PBXGroup;
children = (
DF8DD6DB1ECFEDA0002B3D1A /* Himotoki.framework */,
2F2868971DE7F48A002A6F68 /* Freddy.framework */,
2F2868951DE7F34B002A6F68 /* Freddy.framework */,
9E9BF9C91DCD117300548161 /* PMJSON.framework */,
Expand Down Expand Up @@ -318,6 +332,7 @@
AA2B38D31DC0B6D3008CECCD /* JSON_Tests.swift */,
9E9BF9CB1DCD11BA00548161 /* PMJSON_Tests.swift */,
2F28689B1DE7F66F002A6F68 /* Freddy_Tests.swift */,
DF8DD6E61ED00BE9002B3D1A /* Himotoki_Tests.swift */,
CC5A1A4C1CEAE182007238F3 /* Large.json */,
CC5A1A181CEADE59007238F3 /* Info.plist */,
);
Expand All @@ -343,6 +358,7 @@
20A0B9561DC2584D001D8A14 /* Recording+Genome.swift */,
9E9BF9CF1DCD307200548161 /* Recording+PMJSON.swift */,
2F28689F1DE8843C002A6F68 /* Recording+Freddy.swift */,
DF8DD6E21ECFF695002B3D1A /* Recording+Himotoki.swift */,
71337C921DBEBFB400DCA374 /* Program+Marshal.swift */,
71337C941DBEBFC300DCA374 /* Program+Mapper.swift */,
71337C961DBEBFD000DCA374 /* Program+Unbox.swift */,
Expand All @@ -354,6 +370,7 @@
20A0B9581DC25B60001D8A14 /* Program+Genome.swift */,
9E9BF9CD1DCD126D00548161 /* Program+PMJSON.swift */,
2F28689D1DE7FB58002A6F68 /* Program+Freddy.swift */,
DF8DD6E41ED00848002B3D1A /* Program+Himotoki.swift */,
);
path = ModelObjects;
sourceTree = "<group>";
Expand Down Expand Up @@ -523,6 +540,7 @@
5B69A1DE1DBEC9A400B12579 /* Decodable_Tests.swift in Sources */,
CCD5105B1CFFFF7000E9C0D1 /* SwiftyJSON_Tests.swift in Sources */,
7C3FCD351DC1B61600C82DEE /* Gloss_Tests.swift in Sources */,
DF8DD6E71ED00BE9002B3D1A /* Himotoki_Tests.swift in Sources */,
9E9BF9CC1DCD11BA00548161 /* PMJSON_Tests.swift in Sources */,
681299181DC00DB1009960BE /* ObjectMapper_Test.swift in Sources */,
);
Expand All @@ -541,8 +559,10 @@
6812991B1DC00DBB009960BE /* Program+ObjectMapper.swift in Sources */,
9E9BF9D01DCD307200548161 /* Recording+PMJSON.swift in Sources */,
71337C991DBEBFDC00DCA374 /* Program+SwiftyJSON.swift in Sources */,
DF8DD6E31ECFF695002B3D1A /* Recording+Himotoki.swift in Sources */,
2F28689E1DE7FB58002A6F68 /* Program+Freddy.swift in Sources */,
71337C931DBEBFB400DCA374 /* Program+Marshal.swift in Sources */,
DF8DD6E51ED00848002B3D1A /* Program+Himotoki.swift in Sources */,
CC9786C01CEBAC6C005A5DEA /* NSDate+JSON.swift in Sources */,
9E9BF9CE1DCD126D00548161 /* Program+PMJSON.swift in Sources */,
5B69A1DA1DBEC84200B12579 /* Recording+Decodable.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions JSONShootout.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions JSONShootoutTests/Himotoki_Tests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// Himotoki_Tests.swift
// JSONShootout
//
// Created by yudoufu on 2017/05/20.
// Copyright © 2017年 SwiftBit. All rights reserved.
//

import XCTest
import ModelObjects
import Himotoki

class Himotoki_Tests: XCTestCase {
func testDeserialization() {
self.measure {
let d: NSDictionary = try! JSONSerialization.jsonObject(with: self.data, options: []) as! NSDictionary
XCTAssert(d.count > 0)
}
}

func testPerormance() {
let json = try! JSONSerialization.jsonObject(with: self.data, options: [])

self.measure {
let programs: [Program] = try! decodeArray(json, rootKeyPath: ["ProgramList", "Programs"])
XCTAssert(programs.count > 1000)
}
}

private lazy var data:Data = {
let path = Bundle(for: type(of: self)).url(forResource: "Large", withExtension: "json")
let data = try! Data(contentsOf: path!)
return data
}()
}
4 changes: 2 additions & 2 deletions JSONShootoutTests/SwiftyJSON_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class SwiftyJSON_Tests: XCTestCase {

func testDeserialization() {
self.measure {
let json = JSON(data:self.data as Data)
let json = try! JSON(data:self.data as Data)
XCTAssert(json.count > 0)
}
}

func testPerformance() {
let json = JSON(data:self.data as Data)
let json = try! JSON(data:self.data as Data)
self.measure {
let programRA = json["ProgramList"]["Programs"].arrayValue
let programs = programRA.map(Program.init)
Expand Down
23 changes: 23 additions & 0 deletions ModelObjects/Program+Himotoki.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Program+Himotoki.swift
// JSONShootout
//
// Created by yudoufu on 2017/05/20.
// Copyright © 2017年 SwiftBit. All rights reserved.
//

import Himotoki

extension Program: Decodable {
public static func decode(_ e: Extractor) throws -> Program {
return try Program(
title: e <| "Title",
chanId: e <| ["Channel", "ChanId" ],
description: e <|? "Description",
subtitle: e <|? "SubTitle",
recording: e <| "Recording",
season: (e <|? "Season" as String?).flatMap { Int($0) },
episode: (e <|? "Episode" as String?).flatMap { Int($0) }
)
}
}
20 changes: 20 additions & 0 deletions ModelObjects/Recording+Himotoki.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// Recording+Himotoki.swift
// JSONShootout
//
// Created by yudoufu on 2017/05/20.
// Copyright © 2017年 SwiftBit. All rights reserved.
//

import Himotoki

extension Recording: Decodable {
public static func decode(_ e: Extractor) throws -> Recording {
return try Recording(
startTsStr: e <| "StartTs",
status: (try? e <| "Status") ?? .Unknown,
recordId: e <| "RecordId",
recGroup: (try? e <| "RecGroup") ?? .Unknown
)
}
}
5 changes: 3 additions & 2 deletions ModelObjects/Recording.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
//

import Unbox
import Himotoki

public struct Recording {
enum Status: String, UnboxableEnum {
enum Status: String, UnboxableEnum, Decodable {
case None = "0"
case Recorded = "-3"
case Recording = "-2"
case Unknown
}

enum RecGroup: String, UnboxableEnum {
enum RecGroup: String, UnboxableEnum, Decodable {
case Deleted = "Deleted"
case Default = "Default"
case LiveTV = "LiveTV"
Expand Down