Google_Protobuf_NullValue+Extensions.swift 1.0 KB

12345678910111213141516171819202122232425262728
  1. // Sources/SwiftProtobuf/Google_Protobuf_NullValue+Extensions.swift - NullValue extensions
  2. //
  3. // Copyright (c) 2014 - 2020 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. ///
  11. /// NullValue is a well-known message type that can be used to parse or encode
  12. /// JSON Null values.
  13. ///
  14. // -----------------------------------------------------------------------------
  15. extension Google_Protobuf_NullValue: _CustomJSONCodable {
  16. internal func encodedJSONString(options: JSONEncodingOptions) throws -> String {
  17. "null"
  18. }
  19. internal mutating func decodeJSON(from decoder: inout JSONDecoder) throws {
  20. if decoder.scanner.skipOptionalNull() {
  21. return
  22. }
  23. }
  24. static func decodedFromJSONNull() -> Google_Protobuf_NullValue? {
  25. .nullValue
  26. }
  27. }