Class: Leafy::Json::JsonWriter
- Inherits:
-
Object
- Object
- Leafy::Json::JsonWriter
show all
- Defined in:
- lib/leafy/json/json_writer.rb
Instance Method Summary
collapse
Constructor Details
#initialize(jacksonModule) ⇒ JsonWriter
Returns a new instance of JsonWriter.
7
8
9
|
# File 'lib/leafy/json/json_writer.rb', line 7
def initialize( jacksonModule )
@mapper = ObjectMapper.new.registerModule( jacksonModule )
end
|
Instance Method Details
#data ⇒ Object
11
12
13
|
# File 'lib/leafy/json/json_writer.rb', line 11
def data
raise 'need implementation'
end
|
#to_json(data, pretty = false) ⇒ Object
15
16
17
18
19
20
|
# File 'lib/leafy/json/json_writer.rb', line 15
def to_json( data, pretty = false )
output = java.io.ByteArrayOutputStream.new
writer( pretty ).writeValue(output, data);
output.to_s
end
|