Class: Thrift::JSONPairContext

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

Overview

Context class for object member key-value pairs

Instance Method Summary collapse

Constructor Details

#initializeJSONPairContext

Returns a new instance of JSONPairContext.



92
93
94
95
# File 'lib/thrift/protocol/json_protocol.rb', line 92

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



119
120
121
# File 'lib/thrift/protocol/json_protocol.rb', line 119

def escapeNum
  return @colon
end

#read(reader) ⇒ Object



107
108
109
110
111
112
113
114
115
116
# File 'lib/thrift/protocol/json_protocol.rb', line 107

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



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

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