Class: Thrift::JSONPairContext

Inherits:
JSONContext show all
Defined in:
lib/thrift/protocol/json_protocol.rb

Overview

Context class for object member key-value pairs

Constant Summary collapse

@@kJSONPairSeparator =
':'

Instance Method Summary collapse

Constructor Details

#initializeJSONPairContext

Returns a new instance of JSONPairContext.



81
82
83
84
# File 'lib/thrift/protocol/json_protocol.rb', line 81

def initialize
  @first = true
  @colon = true
end

Instance Method Details

#escapeNumObject

Numbers must be turned into strings if they are the key part of a pair



108
109
110
# File 'lib/thrift/protocol/json_protocol.rb', line 108

def escapeNum
  return @colon
end

#read(reader) ⇒ Object



96
97
98
99
100
101
102
103
104
105
# File 'lib/thrift/protocol/json_protocol.rb', line 96

def read(reader)
  if (@first)
    @first = false
    @colon = true
  else
    ch = (@colon ? @@kJSONPairSeparator : @@kJSONElemSeparator)
    @colon = !@colon
    JsonProtocol::read_syntax_char(reader, ch)
  end
end

#write(trans) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/thrift/protocol/json_protocol.rb', line 86

def write(trans)
  if (@first)
    @first = false
    @colon = true
  else
    trans.write(@colon ? @@kJSONPairSeparator : @@kJSONElemSeparator)
    @colon = !@colon
  end
end