Class: Thrift::JSONPairContext
- Inherits:
-
JSONContext
- Object
- JSONContext
- Thrift::JSONPairContext
- Defined in:
- lib/thrift/json_protocol.rb
Overview
Context class for object member key-value pairs
Instance Method Summary collapse
-
#escapeNum ⇒ Object
Numbers must be turned into strings if they are the key part of a pair.
-
#initialize ⇒ JSONPairContext
constructor
A new instance of JSONPairContext.
- #read(reader) ⇒ Object
- #write(trans) ⇒ Object
Constructor Details
#initialize ⇒ JSONPairContext
Returns a new instance of JSONPairContext.
91 92 93 94 |
# File 'lib/thrift/json_protocol.rb', line 91 def initialize @first = true @colon = true end |
Instance Method Details
#escapeNum ⇒ Object
Numbers must be turned into strings if they are the key part of a pair
118 119 120 |
# File 'lib/thrift/json_protocol.rb', line 118 def escapeNum return @colon end |
#read(reader) ⇒ Object
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/thrift/json_protocol.rb', line 106 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
96 97 98 99 100 101 102 103 104 |
# File 'lib/thrift/json_protocol.rb', line 96 def write(trans) if (@first) @first = false @colon = true else trans.write(@colon ? @@kJSONPairSeparator : @@kJSONElemSeparator) @colon = !@colon end end |