lib/rapidjson/active_support_encoder.rb in rapidjson-0.2.3 vs lib/rapidjson/active_support_encoder.rb in rapidjson-0.3.0
- old
+ new
@@ -12,10 +12,12 @@
end
# Encode the given object into a JSON string
def encode(value)
if @options && !@options.empty?
- value = value.as_json(@options.dup)
+ if !RapidJSON.json_ready?(value) || @options.key?(:only) || @options.key?(:except)
+ value = value.as_json(@options.dup)
+ end
end
json = @coder.dump(value)
if ActiveSupport::JSON::Encoding.escape_html_entities_in_json
json = RapidJSON.json_escape(json)
end