-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feature/2.0.0' into develop
# Conflicts: # JSONPreview.xcodeproj/project.pbxproj
- Loading branch information
Showing
25 changed files
with
1,736 additions
and
932 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
File renamed without changes
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
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
File renamed without changes.
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
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,28 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2021 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Foundation | ||
|
||
public enum JSONError: Swift.Error, Equatable { | ||
case cannotConvertInputDataToUTF8 | ||
case unexpectedCharacter(jsonValue: JSONValue?, ascii: UInt8, characterIndex: Int) | ||
case unexpectedEndOfFile | ||
case tooManyNestedArraysOrDictionaries(characterIndex: Int) | ||
case invalidHexDigitSequence(String, index: Int) | ||
case unexpectedEscapedCharacter(ascii: UInt8, in: String, index: Int) | ||
case unescapedControlCharacterInString(ascii: UInt8, in: String, index: Int) | ||
case expectedLowSurrogateUTF8SequenceAfterHighSurrogate(in: String, index: Int) | ||
case couldNotCreateUnicodeScalarFromUInt32(in: String, index: Int, unicodeScalarValue: UInt32) | ||
case numberWithLeadingZero(index: Int) | ||
case numberIsNotRepresentableInSwift(parsed: String) | ||
case singleFragmentFoundButNotAllowed | ||
} |
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,46 @@ | ||
import Foundation | ||
|
||
/// Used to enrich the information of the key of the object in json. | ||
public struct JSONObjectKey { | ||
/// The object key. | ||
/// | ||
/// If this key is wrong, then the value is `""`. | ||
public let key: String | ||
|
||
/// Is the key wrong. | ||
public let isWrong: Bool | ||
|
||
/// Used to mark an incorrect key. | ||
public static let wrong: Self = .init(key: "", isWrong: true) | ||
|
||
fileprivate init(key: String, isWrong: Bool) { | ||
self.key = key | ||
self.isWrong = isWrong | ||
} | ||
|
||
public init(_ key: String) { | ||
self.init(key: key, isWrong: false) | ||
} | ||
} | ||
|
||
// MARK: - Hashable | ||
|
||
extension JSONObjectKey: Hashable { } | ||
|
||
// MARK: - Comparable | ||
|
||
extension JSONObjectKey: Comparable { | ||
public static func < (lhs: JSONObjectKey, rhs: JSONObjectKey) -> Bool { | ||
if lhs.isWrong { return false } | ||
if rhs.isWrong { return true } | ||
return lhs.key < rhs.key | ||
} | ||
} | ||
|
||
// MARK: - ExpressibleByStringLiteral | ||
|
||
extension JSONObjectKey: ExpressibleByStringLiteral { | ||
public init(stringLiteral value: StringLiteralType) { | ||
self.init(value) | ||
} | ||
} |
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
Oops, something went wrong.