https://www.swift-linux.com/sextant/
Depending on the client used JSONPath expressions do start with $.
indicating the root element.
Some clients omit the leading $.
.
$.store.book[0].title
import Foundation | |
import AnyCodable | |
// This is Fugly but it get the job done. | |
extension AnyCodable { | |
func transmuteThrow<Output: Codable>(_ encoder: JSONEncoder = JSONEncoder(), _ decoder: JSONDecoder = JSONDecoder()) throws -> Output { | |
let data = try encoder.encode(self) | |
return try decoder.decode(Output.self, from: data) | |
} | |
https://www.swift-linux.com/sextant/
Depending on the client used JSONPath expressions do start with $.
indicating the root element.
Some clients omit the leading $.
.
$.store.book[0].title
Objectif : Lister ce à quoi les SDK externes et API tierces doivent se conformer avant d'être intégrés dans l'application Android PagesJaunes.
import Fopundation | |
import Combine | |
extension AnyPublisher { | |
func async<NewOutput>(_ transform: @escaping (Output) throws -> NewOutput) async throws -> NewOutput { | |
try await withCheckedThrowingContinuation { continuation in | |
var cancellable: AnyCancellable? | |
cancellable = first() | |
.sink { result in | |
switch result { |
import Foundation | |
// public struct Model: Codable { | |
// public let test: URL? | |
// public let test2: URL | |
// ... | |
// } | |
// ⚠️ This is not a universal solution tho in orfer to handle properlu fileURL URL should be init with `URL(fileURLWithPath:)` instead of URL(string:) |
import Foundation | |
import Parsing | |
/// A parser that consumes a subsequence from the beginning of its input up to a given parser succeed. | |
/// | |
/// This parser behave a lot like `PrefixUpTo` but it can be slower because it can use a parser instead of | |
/// a static string and consume and return input up to a particular parser succeed. | |
/// | |
/// If provided with a string that correspond to the begining of the parser it will be almost as fast as `PrefixUpTo` in most cases. The only case where it will be slow when providing a string is when there is a lot of false positive aka pattern that look like what the parser should valid but are not valid. | |
/// |
import CoreFoundation | |
import CoreGraphics | |
import Foundation | |
import SwiftUI | |
public let defaultBadColor = Color.green | |
public let defaultGoodColor = Color.red | |
public struct SerializableCGColorError: Error, LocalizedError { | |
let error: String |
import Foundation | |
/// This allow a property to no be encoded | |
@propertyWrapper | |
public struct NotCodable<Boxed> { | |
private var value: Boxed? | |
public init(wrappedValue: Boxed?) { | |
self.value = wrappedValue | |
} |
import Foundation | |
/// This allow to force a default value when using codable | |
/// This will force `isEditMode` to always have `false` when decoding it | |
/// @MockCodable(defaultValue: false) public var isEditMode: Bool = true | |
@propertyWrapper | |
public struct MockCodable<Value> { | |
private var value: Value | |
private var defaultValue: Value | |
import Foundation | |
extension Bundle { | |
func decode<Output: Decodable>( | |
_ type: Output.Type, | |
filename: String, | |
withExtension ext: String, | |
decoder: any TopLevelDecoder = JSONDecoder() | |
) throw -> Output { | |
guard let fileURL = url(forResource: filename, withExtension: ext) else { |