Commit 26951675 by Daniel Dahan

removed JSON file

parent b83b3ea0
......@@ -14,8 +14,6 @@
96264BE91D833D3400576F37 /* RemindersController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96264BE81D833D3400576F37 /* RemindersController.swift */; };
9628645A1D53FE3E00690B69 /* Material+UIWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; };
9628645F1D540AF300690B69 /* DynamicFontType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; };
962864621D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; };
962864631D54111D00690B69 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; };
9631A7C11D95E3AC00CFB109 /* PresenterCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */; };
9631A7C71D95E5D900CFB109 /* Pulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9631A7C61D95E5D900CFB109 /* Pulse.swift */; };
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
......@@ -37,7 +35,6 @@
9697F7C11D8F2572004741EC /* Material+Array.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96C1C8801D42C62800E6608F /* Material+Array.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C21D8F2572004741EC /* Material+UIWindow.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962864591D53FE3E00690B69 /* Material+UIWindow.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C31D8F2572004741EC /* DynamicFontType.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9628645E1D540AF300690B69 /* DynamicFontType.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C41D8F2572004741EC /* JSON.swift in Headers */ = {isa = PBXBuildFile; fileRef = 962864611D54111D00690B69 /* JSON.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C51D8F2573004741EC /* MenuItem.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9697F7B61D8F22A4004741EC /* MenuItem.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C61D8F2573004741EC /* PageTabBarController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963FBF071D669D14008F8512 /* PageTabBarController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9697F7C71D8F2573004741EC /* PhotoLibrary.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96EA9A421D4E68F80052C74D /* PhotoLibrary.swift */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -220,7 +217,6 @@
96264BE81D833D3400576F37 /* RemindersController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemindersController.swift; sourceTree = "<group>"; };
962864591D53FE3E00690B69 /* Material+UIWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Material+UIWindow.swift"; sourceTree = "<group>"; };
9628645E1D540AF300690B69 /* DynamicFontType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontType.swift; sourceTree = "<group>"; };
962864611D54111D00690B69 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
9631A7C01D95E3AC00CFB109 /* PresenterCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresenterCard.swift; sourceTree = "<group>"; };
9631A7C61D95E5D900CFB109 /* Pulse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Pulse.swift; sourceTree = "<group>"; };
96334EF51C8B84660083986B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -383,14 +379,6 @@
name = Reminders;
sourceTree = "<group>";
};
962864601D5410FD00690B69 /* JSON */ = {
isa = PBXGroup;
children = (
962864611D54111D00690B69 /* JSON.swift */,
);
name = JSON;
sourceTree = "<group>";
};
962DDD071D6FBBB7001C307C /* Page */ = {
isa = PBXGroup;
children = (
......@@ -548,7 +536,6 @@
96BCB80A1CB410A100C806FE /* Extension */,
96BCB8071CB4101C00C806FE /* Font */,
96BCB8081CB4105E00C806FE /* Icon */,
962864601D5410FD00690B69 /* JSON */,
96BCB80D1CB410FD00C806FE /* Layer */,
96BCB8041CB40F6C00C806FE /* Layout */,
963FBF021D6696D0008F8512 /* Menu */,
......@@ -864,7 +851,6 @@
9697F7C11D8F2572004741EC /* Material+Array.swift in Headers */,
9697F7C21D8F2572004741EC /* Material+UIWindow.swift in Headers */,
9697F7C31D8F2572004741EC /* DynamicFontType.swift in Headers */,
9697F7C41D8F2572004741EC /* JSON.swift in Headers */,
9697F7C51D8F2573004741EC /* MenuItem.swift in Headers */,
9697F7C61D8F2573004741EC /* PageTabBarController.swift in Headers */,
9697F7C71D8F2573004741EC /* PhotoLibrary.swift in Headers */,
......@@ -1105,7 +1091,6 @@
96BCB7D81CB40DC500C806FE /* MenuController.swift in Sources */,
96BCB7D41CB40DC500C806FE /* TransitionAnimation.swift in Sources */,
967A48191D0F425A00B8CEB7 /* StatusBarController.swift in Sources */,
962864621D54111D00690B69 /* JSON.swift in Sources */,
96264BE71D833D2800576F37 /* Reminders.swift in Sources */,
96BCB7C21CB40DC500C806FE /* Device.swift in Sources */,
96BCB7A41CB40DC500C806FE /* CaptureSession.swift in Sources */,
......@@ -1164,7 +1149,6 @@
buildActionMask = 2147483647;
files = (
9661222E1D3EC414008BB4CB /* Color.swift in Sources */,
962864631D54111D00690B69 /* JSON.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import Foundation
open class JSON: Equatable, CustomStringConvertible {
/**
:name: description
*/
open var description: String {
return JSON.stringify(object) ?? "{}"
}
/**
:name: object
*/
open private(set) var object: Any
/**
:name: asArray
*/
open var asArray: [Any]? {
return object as? [Any]
}
/**
:name: asDictionary
*/
open var asDictionary: [String: Any]? {
return object as? [String: Any]
}
/**
:name: asString
*/
open var asString: String? {
return object as? String
}
/**
:name: asInt
*/
open var asInt: Int? {
return object as? Int
}
/**
:name: asDouble
*/
open var asDouble: Double? {
return object as? Double
}
/**
:name: asFloat
*/
open var asFloat: Float? {
return object as? Float
}
/**
:name: asBool
*/
open var asBool: Bool? {
return object as? Bool
}
/**
:name: asNSData
*/
open var asNSData: Data? {
return JSON.serialize(object: object)
}
/**
:name: parse
*/
open class func parse(_ data: Data, options: JSONSerialization.ReadingOptions = .allowFragments) -> JSON? {
if let object = try? JSONSerialization.jsonObject(with: data, options: options) {
return JSON(object)
}
return nil
}
/**
:name: parse
*/
open class func parse(_ json: String) -> JSON? {
guard let data = json.data(using: String.Encoding.utf8) else {
return nil
}
return parse(data)
}
/**
:name: serialize
*/
open class func serialize(object: Any) -> Data? {
return try? JSONSerialization.data(withJSONObject: object, options: [])
}
/**
:name: stringify
*/
open class func stringify(_ object: Any) -> String? {
if let o = object as? JSON {
return stringify(o.object)
} else if let data = JSON.serialize(object: object) {
if let o = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String {
return o
}
}
return nil
}
/**
:name: init
*/
public required init(_ object: Any) {
if let o = object as? JSON {
self.object = o.object
} else {
self.object = object
}
}
/**
:name: operator [0...count - 1]
*/
open subscript(index: Int) -> JSON? {
if let item = asArray {
return JSON(item[index])
}
return nil
}
/**
:name: operator [key 1...key n]
*/
open subscript(key: String) -> JSON? {
if let item = asDictionary {
if nil != item[key] {
return JSON(item[key]!)
}
}
return nil
}
}
public func ==(lhs: JSON, rhs: JSON) -> Bool {
return JSON.stringify(lhs.object) == JSON.stringify(rhs.object)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment