Class: Aliyun::Log::Record::TypeCasting::JsonType
- Inherits:
-
Value
- Object
- Value
- Aliyun::Log::Record::TypeCasting::JsonType
show all
- Defined in:
- lib/aliyun/log/record/type_casting.rb
Instance Method Summary
collapse
Methods inherited from Value
#initialize
Instance Method Details
#cast(value) ⇒ Object
172
173
174
175
176
177
178
179
180
|
# File 'lib/aliyun/log/record/type_casting.rb', line 172
def cast(value)
return value unless value.is_a?(String)
begin
ActiveSupport::JSON.decode(value)
rescue StandardError
nil
end
end
|
#dump(value) ⇒ Object
182
183
184
|
# File 'lib/aliyun/log/record/type_casting.rb', line 182
def dump(value)
ActiveSupport::JSON.encode(value) unless value.nil?
end
|