Class: Operaton::Bpm::Client::Variable::Impl::Format::Json::JsonDataFormat
- Inherits:
-
Object
- Object
- Operaton::Bpm::Client::Variable::Impl::Format::Json::JsonDataFormat
- Includes:
- Spi::DataFormat
- Defined in:
- lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb
Overview
Stands in for org.operaton.bpm.client.variable.impl.format.json .JacksonJsonDataFormat, using Ruby's JSON library.
Constant Summary collapse
- NAME =
"application/json"
Instance Method Summary collapse
- #can_map(value) ⇒ Object
- #canonical_type_name(value) ⇒ Object
- #name ⇒ Object
-
#read_value(value, _type_identifier = nil) ⇒ Object
type_identifier is the stored objectTypeName; JSON deserialization in Ruby is generic (hashes/arrays), so it is not used for reconstruction the way Jackson uses Java type names.
- #write_value(value) ⇒ Object
Instance Method Details
#can_map(value) ⇒ Object
25 26 27 |
# File 'lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb', line 25 def can_map(value) json_native?(value) || value.respond_to?(:as_json) || value.respond_to?(:to_h) end |
#canonical_type_name(value) ⇒ Object
42 43 44 |
# File 'lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb', line 42 def canonical_type_name(value) value.class.name end |
#name ⇒ Object
21 22 23 |
# File 'lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb', line 21 def name NAME end |
#read_value(value, _type_identifier = nil) ⇒ Object
type_identifier is the stored objectTypeName; JSON deserialization in Ruby is generic (hashes/arrays), so it is not used for reconstruction the way Jackson uses Java type names.
36 37 38 39 40 |
# File 'lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb', line 36 def read_value(value, _type_identifier = nil) JSON.parse(value) rescue JSON::ParserError => e raise DataFormatException.new("Unable to parse JSON value", e) end |
#write_value(value) ⇒ Object
29 30 31 |
# File 'lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb', line 29 def write_value(value) JSON.generate(jsonify(value)) end |