Sha256: c26fd55481941cbf21a69fdf04ce158b9f024d9b3046cf7724c84e9bb970ba85
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
# Copyright 2020 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] 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) end end end
Version data entries
4 entries across 4 versions & 1 rubygems