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.



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

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



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

def escapeNum
  return @colon
end

#read(reader) ⇒ Object



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

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



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

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