Module: Sisimai::Fact::JSON
- Defined in:
- lib/sisimai/fact/json.rb
Overview
Sisimai::Fact::JSON dumps decoded data object as a JSON format. This class and method should be called from the parent object “Sisimai::Fact”.
Class Method Summary collapse
-
.dump(argvs) ⇒ String
Serializer (JSON).
Class Method Details
.dump(argvs) ⇒ String
Serializer (JSON)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sisimai/fact/json.rb', line 10 def dump(argvs) return "" if argvs.nil? || argvs.is_a?(Sisimai::Fact) == false if RUBY_PLATFORM.start_with?('java') # java-based ruby environment like JRuby. begin require 'jrjackson' jsonstring = JrJackson::Json.dump(argvs.damn) rescue StandardError => ce warn '***warning: Failed to JrJackson::Json.dump: ' + ce.to_s end else # MRI begin require 'oj' jsonstring = Oj.dump(argvs.damn, :mode => :compat) rescue StandardError => ce warn '***warning: Failed to Oj.dump: ' + ce.to_s end end return jsonstring end |