class ActiveSupport::JSON::Encoding::Encoder

def as_json(value, use_options = true)

like encode, but only calls as_json, without encoding to string.
def as_json(value, use_options = true)
  check_for_circular_references(value) do
    use_options ? value.as_json(options_for(value)) : value.as_json
  end
end