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.



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

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



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

def escapeNum
  return @colon
end

#read(reader) ⇒ Object



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

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



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

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