1unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED 2 require 'json' 3end 4defined?(::BigDecimal) or require 'bigdecimal' 5 6class BigDecimal 7 # Import a JSON Marshalled object. 8 # 9 # method used for JSON marshalling support. 10 def self.json_create(object) 11 BigDecimal._load object['b'] 12 end 13 14 # Marshal the object to JSON. 15 # 16 # method used for JSON marshalling support. 17 def as_json(*) 18 { 19 JSON.create_id => self.class.name, 20 'b' => _dump, 21 } 22 end 23 24 # return the JSON value 25 def to_json(*) 26 as_json.to_json 27 end 28end 29