Sha256: 6d353a267f8c7b7799fa2c90ad7063a2770f0526fffa098ecf5f45044d7b37a3
Contents?: true
Size: 1.12 KB
Versions: 13
Compression:
Stored size: 1.12 KB
Contents
# Copyright 2020-2021 Couchbase, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require "json" module Couchbase class JsonTranscoder # @param [Object] document # @return [Array<String, Integer>] pair of encoded document and flags def encode(document) [JSON.generate(document), (0x02 << 24) | 0x06] end # @param [String, nil] blob string of bytes, containing encoded representation of the document # @param [Integer, :json] _flags bit field, describing how the data encoded # @return Object decoded document def decode(blob, _flags) JSON.parse(blob) unless blob&.empty? end end end
Version data entries
13 entries across 13 versions & 1 rubygems