 
   /// Return a Data with the decoded contents of the
   /// following base-64 string.
+  ///
+  /// Notes on Google's implementation:
+  ///  * Google's C++ implementation accepts arbitrary whitespace
+  ///    mixed in with the base-64 characters
+  ///  * Google's C++ implementation ignores missing '=' characters
+  ///    but if present, there must be the exact correct number of them.
+  ///  * Google's C++ implementation accepts both "regular" and
+  ///    "web-safe" base-64 variants (it seems to prefer the
+  ///    web-safe version as defined in RFC 4648
   internal mutating func nextBytesValue() throws -> Data {
     skipWhitespace()
     guard hasMoreContent else {
       throw JSONDecodingError.truncated
     }
-    let c = currentByte
-    if c != asciiDoubleQuote {
-      throw JSONDecodingError.malformedString
-    }
-    if let s = parseOptionalQuotedString(),
-      let b = decodeBytes(base64String: s) {
-      return b
-    } else {
-      throw JSONDecodingError.malformedString
-    }
+    return try parseBytes(source: source, index: &index, end: source.endIndex)
   }
 
   /// Private function to help parse keywords.

  }
}

/// Returns a `Data` value containing bytes equivalent to the given
/// Base64-encoded string, or nil if the conversion fails.
private func decodeBytes(base64String s: String) -> Data? {
  var out = [UInt8]()
  let digits = s.utf8
  var n = 0
  var bits = 0
  for (i, digit) in digits.enumerated() {
    n <<= 6
    switch digit {
    case asciiUpperA...asciiUpperZ: n |= Int(digit - asciiUpperA); bits += 6
    case asciiLowerA...asciiLowerZ:
        n |= Int(digit - asciiLowerA + UInt8(26)); bits += 6
    case asciiZero...asciiNine: n |= Int(digit - asciiZero + UInt8(52)); bits += 6
    case 43: n |= 62; bits += 6
    case 47: n |= 63; bits += 6
    case 61: n |= 0
    default:
      return nil
    }
    if i % 4 == 3 {
      out.append(UInt8(truncatingBitPattern: n >> 16))
      if bits >= 16 {
        out.append(UInt8(truncatingBitPattern: n >> 8))
        if bits >= 24 {
          out.append(UInt8(truncatingBitPattern: n))
        }
      }
      bits = 0
    }
  }
  if bits != 0 {
    return nil
  }
  return Data(bytes: out)
}

// JSON encoding allows a variety of \-escapes, including

    throw JSONDecodingError.malformedNumber
  }

  /// Parse a signed integer, quoted or not, including handling
  /// backslash escapes for quoted values.
  ///
