-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
2,422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is largely a copy of code from Swift.org open source project's | ||
// files JSONEncoder.swift and Codeable.swift. | ||
// | ||
// Unfortunately those files do not expose the internal _JSONEncoder and | ||
// _JSONDecoder classes, which are in fact dictionary encoder/decoders and | ||
// precisely what we want... | ||
// | ||
// The original code is copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
// Modifications and additional code here is copyright (c) 2018 Sam Deane, and | ||
// is licensed under the same terms. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
|
||
internal struct DictionaryCodingKey : CodingKey { | ||
public var stringValue: String | ||
public var intValue: Int? | ||
|
||
public init?(stringValue: String) { | ||
self.stringValue = stringValue | ||
self.intValue = nil | ||
} | ||
|
||
public init?(intValue: Int) { | ||
self.stringValue = "\(intValue)" | ||
self.intValue = intValue | ||
} | ||
|
||
public init(stringValue: String, intValue: Int?) { | ||
self.stringValue = stringValue | ||
self.intValue = intValue | ||
} | ||
|
||
internal init(index: Int) { | ||
self.stringValue = "Index \(index)" | ||
self.intValue = index | ||
} | ||
|
||
internal static let `super` = DictionaryCodingKey(stringValue: "super")! | ||
} |
Oops, something went wrong.